三:两级节点的树,展开,无异步

来源:互联网 发布:网络用语pu是什么意思 编辑:程序博客网 时间:2024/04/27 15:10

两级节点的树

效果图:


说明:这是只显示两级节点的树,并且窗体加载的时候树就成展开形式,并不需要异步加载!

Jsp

/**

    * 初始投诉分类

    */

   functionp_initpreclass(){

      //左侧分类树

            treeManager = $("#complaintree").ligerTree({

            url :"../press/prereflectclassify!showtree.action",

            nodeDraggable:false,

            checkbox :false,

            idFieldName :"classid",[d1] 

            parentIDFieldName :"parentid",

             textFieldName  : "name",[d2] 

             nodeWidth: 100,

            onClick :function(node){

               currentClassId = node.data.classid;

              listcomplain(currentClassId);[d3] [d4] 

            },

            single :true           

           });

   }

function listcomplain(classid[d5] ){

      gridManager.setOptions( {

        parms : [ {

        name :'filter_EQL_classid',

        value : classid

        } ]

        });

        gridManager.loadData(true);

   }

Action

 

   public Stringshowtree()  throws Exception{

      List<PropertyFilter> filters = PropertyFilter.buildFromHttpRequest(Struts2Utils.getRequest());

      //classcode = Struts2Utils.getRequest().getParameter("classcode");

      //filters = genFilterList(filters,"LIKES", "classcode", classcode);[d6] 

      List<PreReflectClassify> lRet =manager.listclass(filters);

      JsonConfig config =new JsonConfig();

      config.setExcludes(new String[] {"subsysid","memo","creator","createtime","lastmodify","updater","orders"});

      JSONArray jsonArray = JSONArray.fromObject(lRet,config);

[d7]   Struts2Utils.renderText(jsonArray.toString());

      returnNONE;

   }

//JSONArray jsonArray=new JSONArray();

JSONObject JSONObj=new JSONObject();

for(PreReflectClassify c: lRet){

JSONObj.put(“subsysid”,c.getSubsysid);

JSONObj.put(“memo”,c.getMemo);

……..

jsonArray.add(JSONObj);

}

Struts2Utils.renderText(jsonArray.toString());

[d8] [d9] Service

//投诉分类的处理

   public List<PreReflectClassify>listclass(List<PropertyFilter> filters){

      returnclassdao.find(filters[d10] );

   }

Dao


 [d1]Json中获取的树的id

 [d2]Json拼过来的树的名字

 [d3]

 [d4]点击节点,右侧显示相应的数据

 [d5]指的就是currentClassId

 [d6]添加查询参数

 [d7]封装json类似于:

 

 [d8]d4是一样的结果,这种方式是自己封装的json格式,需要什么字段就封装什么字段

 [d9]filter_EQL_classid

后台不需要做任何处理,只需要把filters传过来就可以了

 [d10]Jsp传的是

原创粉丝点击