`
lauy
  • 浏览: 436011 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

ComBox 树结构

    博客分类:
  • EXT
阅读更多
前台代码  树的渲染

 var Tree = Ext.tree;      
       var <%=proName%>_Tree = new Tree.TreePanel({
          el:'tree1',   
          useArrows:false,
          autoScroll:true,
          animate:true,
          height:winHeight,
          enableDD:false,
          border:false,
          containerScroll:true,
          onSelect:Ext.emptyFn   
      });
     
    var Tree = Ext.tree;  
    var tree1 =  new Tree.TreePanel({   
      loader: new Tree.TreeLoader({dataUrl:'<%=treeDataUrl%>?parentId=0'}),   
      border:false,   
      root:new Ext.tree.AsyncTreeNode({text: '产品类型',id:'0'})   
     });   
     var id="";
     tree1.on('click',function(node){   
       var nodeId = node.id;
       //Ext.getCmp('emyt_item_class').setValue(nodeId);       
       tree1.loader.dataUrl = '<%=treeDataUrl%>?parentId='+nodeId;
       id=nodeId; 
       node.toggle(); 
       var content ='';
        <%=proName%>_store.baseParams = {actionDo:'quick',content:content,icateId:encodeURI(nodeId),groupId:'<%=groupId%>'};
           <%=proName%>_store.load({params:{start:0,limit:10}});
           Ext.getCmp('treeId').setValue(node.text);
     });     
   tree1.on('beforeload', function(node)
   {
    var nodeId = node.id;
       tree1.loader.dataUrl = '<%=treeDataUrl%>?parentId='+nodeId; 
            
      }); 


combox的处理:

new Ext.form.ComboBox({   
        store:new Ext.data.SimpleStore({fields:[],data:[[]]}),   
        editable:false,
        fieldLabel:'产品类型',   
        shadow:false,   
        mode: 'local',
        width:150, 
        id:'treeId',  
        triggerAction:'all',   
        maxHeight: 300,   
        tpl: '<tpl for="."><div style="height:200px"><div id="tree1"></div></div></tpl>',   
        selectedClass:'',   
        onSelect:Ext.emptyFn,
       listeners:{'expand': comboBoxexpand }

 

 function comboBoxexpand(){ 
     tree1.render('tree1');         
    }


部分后台代码:

 String parentId=request.getParameter("parentId");   
     if(parentId==null)
     {
      parentId="0";
     }    
     hs.put("parentId",parentId);      
     List li = ca.queryAll(tableName,className,hs,null);
     for(int i=0;i<li.size();i++)
     {
      formClass.base.EmytIcategory productClass = (formClass.base.EmytIcategory)li.get(i);
      json += "{text:'"+productClass.getFolderName()+"',parentId:'"+productClass.getParentId()+"',allClassId:'"+productClass.getAllClassId()+"',id:'"+productClass.getId()+"'},";
     }
     if(json.length()>0)
  {
   json = json.substring(0,json.length()-1);
  }
  json = "["+json+"]";     
  response.setContentType("application/x-json");
        response.getWriter().write(json);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics