sdbrk
2014-04-16 11:04:37
extjs2下拉树选项框comboxWithTree(支持异步加载子节点)
extjs版本:2.2
简介:支持单选、异步加载子节点(当然一下子拼接好全部节点的json也是绝对没问题的),要支持多选则需要自行设置,(已测试通过)浏览器兼容ie8、谷歌、FF。
资料参考:搜索一下“ext2 下拉树”,应该有一大堆内容代码介绍完全一样的博文,下面代码就是取自那堆“原创”的博文,不能说明出处,望原作者见谅。本代码在那个基础上有较好的修改:1、修改tree的lorder使tree支持异步加载子节点;2、使下拉树由多选转为单选。
代码如下:
/区域下拉树(ext2) var comboxWithTree = new Ext.form.ComboBox({ fieldLabel:'区域', id:'zonename', //hiddenName:'zonename', displayField:'code',valueField:'value',mode:'local', store:new Ext.data.SimpleStore({fields:[],data:[[]]}), editable:false, shadow:false, triggerAction:'all', maxHeight: 200, anchor:'98%', tpl:"<div style='height:200px'><div id='tree4combox'></div></div>" }); var treelorder = new Ext.tree.TreeLoader({ dataUrl : fullpath+'/systemextend/UserZoneAction!listUserZoneTree4combo.do' }); treelorder.on("beforeload",function(treeloader,node){ treelorder.baseParams.comboTreeid = node.attributes.id; },treelorder); var tree4combox = new Ext.tree.TreePanel({ border : true, rootVisible : true, root : { text:'全国', id:'-1', expanded : true }, loader : treelorder }); tree4combox.on('click',function(node){ //点击选中 comboxWithTree.setValue(node.text); comboxWithTree.collapse(); }); tree4combox.on('checkchange',function(node,checked ){ //勾选复选框选中并清空复选框 if(checked==true){ node.getUI().toggleCheck(false); comboxWithTree.setValue(node.text); comboxWithTree.collapse(); } }); comboxWithTree.on('expand',function(){ tree4combox.render('tree4combox'); });
由最代码官方编辑于2016-4-30 10:21:37
猜你喜欢
请下载代码后再发表评论
![最代码相关代码源代码列表](https://static.zuidaima.com/resource/img/heart_ico.png)
![最代码最近下载分享源代码列表](https://static.zuidaima.com/resource/img/heart_ico.png)
![最代码最近浏览分享源代码列表](https://static.zuidaima.com/resource/img/cattle_ico.png)
chongminzheng LV1
7月13日
9323249323 LV13
2023年7月25日
dzlwindy LV8
2023年7月10日
mengfanyun LV9
2022年7月1日
黑手疯狂 LV5
2022年1月17日
aaaahao LV13
2021年8月26日
tu20201022 LV1
2020年10月22日
assadd LV9
2020年7月16日
e307911 LV7
2020年5月30日
a58807333 LV9
2020年4月2日