No more nonsense to say, directly to everyone paste code.
The specific code looks like this:
1. Front End
<%@ page language= "java" pageencoding= "UTF-8" contenttype= "text/html; Charset=utf-8 "%> <script type=" Text/javascript "> $ (Function () {$ (' #goods_type_treegrid '). Treegrid ({URL: ' $ {pagecontext.request.contextpath}/admin/goodstypecontroller/treegrid.do?id=null ', IdField: ' id ', TreeField: ' Text ' , Rownumbers:true, ParentField: ' pid ', Fit:true, Fitcolumns:true, Border:false, frozencolumns: [[{title: ' Number ' , field: ' ID ', width:150, hidden:true}, {field: ' Text ', title: ' Category name ', width:200}], columns: [[{field: ' PName ', title: ' Superior category name ', width:80},{field: ' seq ', title: ' Sort ', width:50},{field: ' Code ', Title: ' Category Code ', wid
Th:50}, {field: ' pid ', title: ' Superior Category ID ', width:150, hidden:true}, {field: ' Action ', title: ' Action ', WIDTH:50, Formatter:function (value, row, index) {return formatstring (' <table id= "Goods_type_treegrid" ></table>
2, CONTROLLER
@RequestMapping ("/treegrid")
@ResponseBody public
list<goodstypepage> Treegrid (goodstypepage Goodstypepage) {
if (Null==goodstypepage | | "". Equals (Goodstypepage.getid ()) | | Null = = Goodstypepage.getid ()) {
Goodstypepage.setid ("null");
}
Return Goodstypeservice.treegrid (goodstypepage);
}
3. Service
@Override//Cached data public list<goodstypepage> Treegrid (Goodstypepage goodstypepage)
{String hql = ""; if (Null==goodstypepage | | "". Equals (Goodstypepage.getid ()) | | Null ". Equals (Goodstypepage.getid ())) {hql =" from Goodstype t where t.tgoodstype.id are null order by T.seq ";}
else{hql = "from Goodstype t where t.tgoodstype.id = '" +goodstypepage.getid () + "ORDER by T.seq";}
list<goodstype> brlist = Goodstypedao.find (HQL);
list<goodstypepage> nl = new arraylist<goodstypepage> ();
if (brlist!= null && brlist.size () > 0) {for (Goodstype br:brlist) {goodstypepage r = new Goodstypepage ();
Beanutils.copyproperties (BR, R);
if (Br.gettgoodstype ()!=null) {R.setpname (Br.gettgoodstype (). GetText ()); R.setpid (Br.gettgoodstype (). GetId ());
R.setstate ("closed");
Nl.add (R);
} return NL; }