赞
踩
api:API Document [zTree -- jQuery tree plug-ins.]
碰一个问题:选中父节点,展开子节点并默认选中子节点,结果怎么处理都不起作用。
selectZoneTreeSetting = {
check: {
enable: true,
chkStyle: "checkbox",
radioType: "all"
},
async : {
enable : true
}
callback: {
onAsyncSuccess: zTreeOnAsyncSuccess,
beforeCheck: zTreeBeforeCheck
}
}
function onNodeClick(e,treeId, treeNode) {
var zTree = $.fn.zTree.getZTreeObj("selectZoneTree");
zTree.expandNode(treeNode); //展开节点
}
function zTreeOnAsyncSuccess(event, treeId, treeNode, msg){
if(treeNode){
var zTree = $.fn.zTree.getZTreeObj(treeId);
var nodes = JSON.parse(msg);
nodes.forEach(function(node,i){
/*if(node.isParent){//判断是否为父节点
zTree.expandNode(node,true, true,true);
}*/
if(treeNode.checked)
{
var tt_node = zTree.getNodeByParam("id",node.id , null);
tt_node .checked = true;
zTree.updateNode(tt_node );
//zTree.reAsyncChildNodes(node, "refresh");
}
});
}
}
备忘问题------------------------------------------------------------------------------------------------------
原来是这样写-----------------------------------------
node .checked = true;
zTree.updateNode(node );
------------------------------------------------------------一直没有效果。
后面改成----------------------------------------------------
var tt_node = zTree.getNodeByParam("id",node.id , null);
tt_node .checked = true;
zTree.updateNode(tt_node );
-----------------------------------------------------------------就可以了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。