使用easyui tree时,希望实现只要有某一个子节点被选中时,父节点也要被选中,
因为按照其默认实现,只有所有的子节点都选中了,父节点才会被打勾,而且在
提交时还不会被提交到后台,这样满足不了我的需求,我希望做到,只要有一个
子节点被选中,父节点都会被选中并在提交时提交到后台,求如何实现
机器人的方法可以,但是需要配置cascadeCheck为false,要不勾选子节点后会导致多有节点被勾选
onCheck:function(node){ //
var node1=$(tree).tree('getParent',node.target);
$(tree).tree('check', node1.target);
}......
答案就在这里:easyui tree 子节点选中时,父节点也选中
----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。
直接得到父节点属性 然后设置为选中
我也遇到相同的问题,不知道楼主解决了没有,我也想着是如果选中任意子节点的话,也默认选中父节点。不知道楼主是否是这样解决的。请楼主赐教!!!
getChecked state 获取所有选中的节点。'state'可用值有:'checked','unchecked','indeterminate'。如果'state'未指定,将返回'checked'节点。
代码示例:
var nodes = $('#tt').tree('getChecked'); // get checked nodes
var nodes = $('#tt').tree('getChecked', 'unchecked'); // 获取未选择节点
var nodes = $('#tt').tree('getChecked', 'indeterminate'); // 获取不确定的节点
译者注:(1.3.4新增获取方式)var nodes = $('#tt').tree('getChecked', ['unchecked','indeterminate']);
用以下方法获取:
var nodes = $('#updatengqx').tree('getChecked', ['checked','indeterminate']);