$scope.initZtreeData = url = = res.respData; setting = zTree = $.fn.zTree.init($( functionLimitList = $.fn.zTree.getZTreeObj(
functionLimitList.setting.check.chkboxType = { "Y" : "ps", "N" : "ps" };//checkbox 选中/取消选中的时候关联到父子节点 p-父 s-子
<span style="color: #000000">}).error(function(){}); }; $scope.initZtreeData(); function zTreeOnCheck(){ $scope.getNodeDetail(); };<br><br><br>//点击节点时执行的回调</span>
$scope.getNodeDetail = function () { var treeObj = $.fn.zTree.getZTreeObj("functionLimitList"); var node = treeObj.getSelectedNodes();//点击节点后 获取节点数据 $scope.id = node[0].id; };
<br>
默认选中节点:(备注:默认选中的方法应该在树成功以后调用 才能保证每次check成功)
$scope.roleZtreeDafultNodes = function () {var url = '/';//接口名var params = {// 参数 }; $http.post(url,params).success(function(res){var list = [110101,110102];//res.data里 获取到的节点idfor(var i=0;i<list.length;i++){var node = zTree.getNodeByParam("id",list[i]); zTree.checkNode(node); zTree.expandNode(node, true, true,true); zTree.selectNode(node); }; }).error(function(){}); }; $scope.roleZtreeDafultNodes();
以上是angular ztree 梯形结构详解的详细内容。更多信息请关注PHP中文网其他相关文章!