ztree
//知识点树形结构 var zTree; var setting = { async: { //异步加载 enable: true, url: basePath+"/web/teacher/question/queryTreeKonwledge.action?subjectid=${subjectId}", autoParam: ["id=id"] //需要传递的参数
otherParam: ["subjectid",function(){return $("#subjectid").val();}]
},
view: { dblClickExpand: true,//定义双击展开 showLine: true, selectedMulti: true }, data: { simpleData: { enable:true, idKey: "id", pIdKey: "pId", rootPId: "" } }, callback: { beforeClick:function(treeId, treeNode){ if (treeNode.isParent) { zTree.expandNode(treeNode); return false; } else { return true; } },onAsyncSuccess:function(){ var kPointIds=$("#kPointId").val().split(','); var kPointStr=""; for(var i=0;i<kPointIds.length;i++){ if(kPointIds[i]!=""){ var node = zTree.getNodeByParam("id",kPointIds[i], null); kPointStr+=combStr(node.id,node.name); zTree.selectNode(node,false); } } $("#knowlist").empty().append(kPointStr); } } }; $(document).ready(function(){ //获取知识点数据 zTree=$.fn.zTree.init($("#tree"), setting); }); //知识点弹出框 function addKnow(){ //页面层 layer.open({ type: 1, title: '选择知识点', skin: 'layui-layer-rim', //加上边框 area: ['740px', '420px'], //宽高 content: $('#knowledgeTree'), shift: -1, btn: ['确定', '取消'], yes: function(index){ layer.close(index); nodes=zTree.getSelectedNodes(true), kPointStr=""; for(var i=0;i<nodes.length;i++){ kPointStr+=combStr(nodes[i].id,nodes[i].name); } $("#knowlist").empty().append(kPointStr); } }); } //知识点删除 function deltreenode(e,id){ $(e).parent("li").remove(); var node = zTree.getNodeByParam("id",id, null); zTree.cancelSelectedNode(node); }