$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中文網其他相關文章!