ฉันจะไม่พูดเรื่องไร้สาระมากฉันจะโพสต์รหัสให้คุณ
รหัสเฉพาะมีดังนี้:
1. ปลายด้านหน้า
<%@ page language = "java" pageencoding = "utf-8" contentType = "text/html; charset = utf-8"%> <script type = "text/javascript"> $ (function () {$ ('#goods_type_treegrid') '$ {pageContext.request.contextpath} /admin/goodstypecontroller/treegrid.do?id=null', didfield:' id ', treefield:' text ', rownumbers: true, parentfield:' pid ', พอดี: จริง : 150, ซ่อน: true}, {ฟิลด์: 'ข้อความ', ชื่อเรื่อง: 'ชื่อหมวดหมู่', ความกว้าง: 200}]], คอลัมน์: [[{ฟิลด์: 'pname', ชื่อเรื่อง: 'ชื่อหมวดหมู่ที่เหนือกว่า', ความกว้าง: 80}, {ฟิลด์: 'seq', ชื่อ: : 'PID', ชื่อเรื่อง: 'ID หมวดหมู่ที่เหนือกว่า', ความกว้าง: 150, ซ่อน: true}, {ฟิลด์: 'การกระทำ', ชื่อ: 'การกระทำ', ความกว้าง: 50, formatter: ฟังก์ชัน (ค่า, แถว, ดัชนี) {return formatstring ('<img onclick = "goods_type_editfun (/' '$ {pageContext.request.contextpath} /style/images/extjs_icons/pencil.png', row.id, '$ {pageContext.request.contextpath}/style/images/extjs_icons/cancel.png'); นำเข้า ', iconcls:' icon-remove ', handler: function () {goods_type_importfun ();}}, {text:' add ', iconcls:' icon-add ', handler: {text: {text: {text: {text: {text: {text: function () {var node = $ ('#goods_type_treegrid'). treegrid ('getSelected'); ถ้า (โหนด) {$ ('#goods_type_treegrid'). treegrid ('ขยาย allegrid' '' ')}} '-', {text: 'fold', iconcls: 'icon-undo', handler: function () {var node = $ ('#goods_type_treegrid'). treegrid ('getSelected'); ถ้า (โหนด) {$ ('#goods_type_treegrid'). treegrid ('clounpraseAll');}}}, '-', {text: 'Refresh', ไอคอน: ], onbeforeexpand: ฟังก์ชั่น (แถว) {// การตั้งค่าแบบไดนามิกของ URL VAR URL สำหรับการขยายการสืบค้น var url = '$ {pageContext.request.context.context.context.context. }, OnContextMenu: ฟังก์ชั่น (E, แถว) {E.PreventDefault (); $ (นี่) .TreeGrid ('unSelectall'); $ (นี่) .TreeGrid ('เลือก', row.id); $ ('#goods_type_menu') ฟังก์ชั่น (แถว) {var children = $ ("#goods_type_treegrid"). treegrid ('getchildren', row.id); ถ้า (children.length <= 0) {row.leaf = true; $ ("#goods_type_treegrid"). treegrid (' id = "goods_type_treegrid"> </table>2. คอนโทรลเลอร์
@RequestMapping ("/treegrid")@repectionbodypublic list <woodstypepage> treegrid (goodstypepage goodstypepage) {ถ้า (null == goodstypepage || "". equals (goodstypepage.getid ()) goodstypeservice.treegrid (goodstypepage);}3. บริการ
@override // cache data รายการสาธารณะ <woodstypepage> treegrid (goodstypepage goodstypepage) {string hql = ""; ถ้า (null == goodstypepage || "" .equals (goodstypepage.getid ()) t.tgoodstype.id เป็นคำสั่ง null โดย t.seq ";} else {hql =" จาก goodstype t โดยที่ t.tgoodstype.id = '" +goodstypepage.getid () +"' ลำดับโดย t.seq "; ArrayList <Goodstypepage> (); ถ้า (brlist! = null && brlist.size ()> 0) {สำหรับ (goodstype br: brlist) {goodstypepage r = new goodstypepage (); beanutils.copyproperties r); if (br.gettgoodtype ()! = null) {r.setpname (br.gettgoodtype (). getText ()); r.setpid (br.gettgoodtype (). getid ());} r.setstate ("ปิด");