try {
var arrs = $('#subjectClassID').val().split(",");
var treeObj = $.fn.zTree.getZTreeObj("subjecttree");
//checkNode(treeNode, checked, checkTypeFlag, callbackFlag)
//treeNode(json):节点数据;checked(Boolean):勾选节点或取消勾选;checkTypeFlag(Boolean):父子节点勾选联动;callbackFlag(Boolean):事件回调函数
for (var e in arrs) {
treeObj.checkNode(treeObj.getNodeByParam("id", arrs[e], null), true, true,false);
}
zTreeOnCheck();//勾选ID集合后执行事件
} catch (e) {
alert(a.message);
}
前提是要先加载完成zTree后才能正常显示数据,也就是说在ajax里需要添加async:false,