• ztree jquery 树 控件


    插件地址:http://www.ztree.me

    数据:[{"id":1,"pId":-1,"name":"根目录"},{"id":2,"pId":1,"name":"子目录1"}]

    <ul id="tree" class="ztree" style="padding: 0px 0px;"></ul>
    $.ajax({
            method: 'get',
            url: 'api/ZTree/Get',
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                
                $.fn.zTree.init($("#tree"), {
                    view: {
                        showIcon: true,
                        showLine: true,
                        showTitle: true
                    },
                    data: {
                        simpleData: {
                            enable: true,
                            idKey: "id",
                            pIdKey: "pId",
                            rootPId:-1
                        },
                        key: { 
                            title: "Info"
                        }
                    },
    
                    callback: {
                        onClick: function (event,treeId,treeNode,clickFlag) {
                            console.log(treeNode)
                        }
                    }
                }, eval(data));
            }
        });
    var cid = $.request.queryString["mid"];
               if (cid != null) {
                   var treeObj = $.fn.zTree.getZTreeObj("tree_Doc");
                   var node = treeObj.getNodeByParam("id", cid, null);
                   if (node != null) {
                       treeObj.selectNode(node);
                   }
               }
    $.request = (function () {
    	var apiMap = {};
    	function request(queryStr) {
    		var api = {};
    		if (apiMap[queryStr]) { return apiMap[queryStr]; }
    		api.queryString = (function () {
    			var urlParams = {};
    			var e,
    			d = function (s) { return decodeURIComponent(s.replace(/+/g, " ")); },
    			q = queryStr.substring(queryStr.indexOf('?') + 1),
    			r = /([^&=]+)=?([^&]*)/g;
    			while (e = r.exec(q)) 	urlParams[d(e[1])] = d(e[2]);
    			return urlParams;
    		})();
    		api.getUrl = function () {
    			var url = queryStr.substring(0, queryStr.indexOf('?') + 1);
    			for (var p in api.queryString) { url += p + '=' + api.queryString[p] + "&";		}
    			if (url.lastIndexOf('&') == url.length - 1) { return url.substring(0, url.lastIndexOf('&')); }
    			return url;
    		}
    		apiMap[queryStr] = api;
    		return api;
    	}
    	$.extend(request, request(window.location.href));
    	return request;
    })();
    $.request
  • 相关阅读:
    软件的结构
    SpringMVC返回值类型及响应数据类型
    mybatis学习日记3
    面试八
    面试七
    微信小程序实例源码大全下载
    dot.js模板引擎,避免大量拼接字符串
    前端重构方案了解一下
    微信小程序开发基础教程
    如何让签到成为提升用户活跃度的利器
  • 原文地址:https://www.cnblogs.com/CodingArt/p/5701284.html
Copyright © 2020-2023  润新知