• 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);
        }
  • 相关阅读:
    Linux Virtual Server技术
    log4j+slf4j迁移到log4j2+slf4j (Servlet3.0)
    Android控件ToggleButton的使用方法
    Redis学习手冊(事务)
    游戏server之server优化思路
    Codeforces 474D Flowers (线性dp 找规律)
    【C语言】编写函数实现库函数atof
    unity3D游戏开发实战原创视频讲座系列7之消消乐游戏开发
    [WebGL入门]二十一,从平行光源发出的光
    TwoSum leetcode
  • 原文地址:https://www.cnblogs.com/jcz1206/p/4998049.html
Copyright © 2020-2023  润新知