easyui combotree 异步加载节点 默认值 问题
2015-12-15 10:21
471 查看
关于easyui combotree在异步加载子节点的时候由于没有加载的层级比较深的子节点,那么默认值就会直接是以id的形式显示的combotree的文本框中,因为这个时候需要被匹配的那个节点根本没有加载出来,所以只能显示id。
网上基本上没有这个问题的解决方案,研究了一下想到了一个解决方案,暂且不说是最好的,但是至少能解决问题,下面开始讲解。
楼主我通过在combotree初始化时在onLoadSuccess事件中调用一个自定义函数来进行初始化。下面这个combotree是异步加载子节点,异步加载原理是什么这不是讨论重点。
来说一说思路,defalutValue函数通过对combotree的tree对象追加一个用户想要的默认值节点,并使其隐藏来达到设置默认值的效果。
![](http://img.blog.csdn.net/20151215102922110?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
这个时候,就已经设置完成,默认值文本为‘默认值文本’,默认值为‘100’。
网上基本上没有这个问题的解决方案,研究了一下想到了一个解决方案,暂且不说是最好的,但是至少能解决问题,下面开始讲解。
楼主我通过在combotree初始化时在onLoadSuccess事件中调用一个自定义函数来进行初始化。下面这个combotree是异步加载子节点,异步加载原理是什么这不是讨论重点。
来说一说思路,defalutValue函数通过对combotree的tree对象追加一个用户想要的默认值节点,并使其隐藏来达到设置默认值的效果。
$("#moduls_funbase_sysmgr_addUnit_combotree").combotree({ url : '${pageContext.request.contextPath}/base_sysmgr_demoController/getUnitParamTree.do?superunitid1=', valueField:'id', textField:'text', parentField:'pid', panelWidth:'200', onClick : function(node) { //console.log(node); }, onBeforeExpand:function(node,param){ $(this).tree('options').url = '${pageContext.request.contextPath}/base_sysmgr_demoController/getUnitParamTree.do?superunitid1='+node.id; }, onLoadSuccess:function(node,data){ defaultValue('moduls_funbase_sysmgr_addUnit_combotree','100','默认值文本');//这个方法就是解决默认值的问题核心 } });
//slk/2015-12-10 //为combotree增加默认值隐藏节点,解决因异步加载导致默认值id直接显示到文本框中的问题 //cbtid:combotree的id //defval:生成节点的id //deftext:生成节点的文本用于显示 function defaultValue(cbtid,defVal,defText){ var combotree =$("#"+cbtid); var tree = combotree.combotree('tree'); var defNode = tree.tree("find",defVal); if(!defNode){ tree.tree('append', { data: [{ id: defVal, text: defText }] }); defNode = tree.tree("find",defVal); //console.log(defNode); //console.log(combotree); combotree.combotree('setValue',defVal); tree.tree('select',defNode.target); defNode.target.style.display='none'; }else{ combotree.combotree('setValue',defVal); } }
这个时候,就已经设置完成,默认值文本为‘默认值文本’,默认值为‘100’。
相关文章推荐
- 记录错误:'command '/.../sdk/build-tools/23.0.1/aapt'' finished with non-zero exit value 1
- easyUI在可编辑的datagrid中计算两列的值
- Java GUI入门教程
- 应用Druid监控SQL语句的执行情况
- UIViewContentMode各类型效果
- Querying JSON
- ORA-12520: TNS:listener could not find available handler for requested type of server
- 详解iOS开发中UItableview控件的数据刷新功能的实现
- Arduino - 改装车库门,增设手机蓝牙控制功能
- ios UITableview 刷新某一个cell 或 section
- 《UIPageControl 的创建和 自定义和引导页的使用》
- iOS9 新增 UIStackView 官方文档翻译
- iOS UIScrollView 没有从顶部开始滑动
- Arduino - Micro SD卡 读写
- 298. Binary Tree Longest Consecutive Sequence
- iOS之UI--使用SWRevealViewController实现侧边菜单功能详解实例
- setProjectionMap@SQLiteQueryBuilder使用简记
- Android Service更新UI的方法之AIDL
- HDU 1242 Rescue
- UILabel的富文本设置