Ext combox 树的实现

前台代码  树的渲染


  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);

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值