提交 4b802756 编写于 作者: Z zTreeAPI

* Support attribute('name' & 'title') dynamic rendering using custom function Thanks @imyuyu

上级 d605bbf3
jQuery Tree Plugin ---- zTree jQuery Tree Plugin ---- zTree
============ ============
last verson : 3.5.44 last verson : 3.5.45
**Donate to zTree** : http://www.treejs.cn/v3/donate.php **Donate to zTree** : http://www.treejs.cn/v3/donate.php
...@@ -12,6 +12,12 @@ zTree API : http://www.treejs.cn/v3/api.php ...@@ -12,6 +12,12 @@ zTree API : http://www.treejs.cn/v3/api.php
zTree Demo : http://www.treejs.cn/v3/demo.php zTree Demo : http://www.treejs.cn/v3/demo.php
Install
============
```
npm install @ztree/ztree_v3
```
Introduction of zTree (简介) Introduction of zTree (简介)
============ ============
* zTree is a multi-functional "tree plug-ins." based on jQuery. The main advantages of zTree includes excellent performance, flexible configuration, and the combination of multiple functions. * zTree is a multi-functional "tree plug-ins." based on jQuery. The main advantages of zTree includes excellent performance, flexible configuration, and the combination of multiple functions.
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<div class="ieSuggest">浏览本网站建议您使用 Chrome、FireFox、Opera、IE9 等浏览器(只要不是 IE6 7 8 就行), 速度会更快,画面会更炫!</div> <div class="ieSuggest">浏览本网站建议您使用 Chrome、FireFox、Opera、IE9 等浏览器(只要不是 IE6 7 8 就行), 速度会更快,画面会更炫!</div>
<div class="google_plus"><g:plusone></g:plusone></div> <div class="google_plus"><g:plusone></g:plusone></div>
<div class="header-text"> <div class="header-text">
<h1><em>zTree v3.5.44 API 文档</em></h1><p></p> <h1><em>zTree v3.5.45 API 文档</em></h1><p></p>
<p>all.js = core + excheck + exedit ( 不包括 exhide ); 发现错误请及时通知,谢谢。</p> <p>all.js = core + excheck + exedit ( 不包括 exhide ); 发现错误请及时通知,谢谢。</p>
</div> </div>
<ul class="shortcuts language" style="top:0;"> <ul class="shortcuts language" style="top:0;">
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<div class="ieSuggest">If you use the Chrome / FireFox / Opera / IE9 browser will be even more dazzling effect!</div> <div class="ieSuggest">If you use the Chrome / FireFox / Opera / IE9 browser will be even more dazzling effect!</div>
<div class="google_plus"><g:plusone></g:plusone></div> <div class="google_plus"><g:plusone></g:plusone></div>
<div class="header-text"> <div class="header-text">
<h1><em>zTree v3.5.44 API Document</em></h1><p></p> <h1><em>zTree v3.5.45 API Document</em></h1><p></p>
<p>all.js = core + excheck + exedit ( without exhide ); if you found some mistakes please contact me.</p> <p>all.js = core + excheck + exedit ( without exhide ); if you found some mistakes please contact me.</p>
</div> </div>
<ul class="shortcuts language" style="top:0;"> <ul class="shortcuts language" style="top:0;">
......
...@@ -147,7 +147,12 @@ var apiContent = { ...@@ -147,7 +147,12 @@ var apiContent = {
{id:5202, pId:520, t:"idKey", name:"idKey : \"id\",", iconSkin:"core", showAPI:true}, {id:5202, pId:520, t:"idKey", name:"idKey : \"id\",", iconSkin:"core", showAPI:true},
{id:5203, pId:520, t:"pIdKey", name:"pIdKey : \"pId\",", iconSkin:"core", showAPI:true}, {id:5203, pId:520, t:"pIdKey", name:"pIdKey : \"pId\",", iconSkin:"core", showAPI:true},
{id:5204, pId:520, t:"rootPId", name:"rootPId : null", iconSkin:"core", showAPI:true}, {id:5204, pId:520, t:"rootPId", name:"rootPId : null", iconSkin:"core", showAPI:true},
{id:521, pId:50, name:"}"}, {id:521, pId:50, name:"},"},
{id:530, pId:50, t:"render", name:"render : {", open:true},
{id:5301, pId:530, t:"name", name:"name : null,", iconSkin:"core", showAPI:true},
{id:5302, pId:530, t:"title", name:"title : null", iconSkin:"core", showAPI:true},
{id:531, pId:50, name:"}"},
{id:51, pId:1, name:"},"}, {id:51, pId:1, name:"},"},
{id:52, pId:1, name:""}, {id:52, pId:1, name:""},
......
此差异已折叠。
<div class="apiDetail">
<div>
<h2>
<span>Function(name, treeNode)</span
><span class="path">setting.data.render.</span>name
</h2>
<h3>
概述<span class="h3_info"
>[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 核心 js
]</span
>
</h3>
<div class="desc">
<p></p>
<div class="longdesc">
<p>用于使用自定义的方法动态渲染节点名称</p>
<p>默认值:null</p>
<p class="highlight_red">v3.5.45+</p>
</div>
</div>
<h3>Function 参数说明</h3>
<div class="desc">
<h4><b>name</b><span>String</span></h4>
<p>对应 zTree 利用 setting.key.name 获取到的节点名称</p>
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<p>待渲染节点的 JSON 数据对象</p>
<p class="highlight_red">针对根进行渲染时,treeNode = null</p>
<h4 class="topLine"><b>返回值</b><span>Boolean</span></h4>
<p>返回值是 渲染后的节点名称</p>
</div>
<h3>setting & function 举例</h3>
<pre xmlns=""><code>
var setting = {
data: {
render: function(name,treeNode){
return name + treeNode.id;
}
}
};
......</code></pre>
</div>
</div>
<div class="apiDetail">
<div>
<h2>
<span>Function(title, treeNode)</span
><span class="path">setting.data.render.</span>title
</h2>
<h3>
概述<span class="h3_info"
>[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 核心 js
]</span
>
</h3>
<div class="desc">
<p></p>
<div class="longdesc">
<p>用于使用自定义的方法动态渲染节点标题</p>
<p>默认值:null</p>
<p class="highlight_red">v3.5.45+</p>
</div>
</div>
<h3>Function 参数说明</h3>
<div class="desc">
<h4><b>title</b><span>String</span></h4>
<p>对应 zTree 利用 setting.key.title 获取到的节点标题</p>
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<p>待渲染节点的 JSON 数据对象</p>
<p class="highlight_red">针对根进行渲染时,treeNode = null</p>
<h4 class="topLine"><b>返回值</b><span>Boolean</span></h4>
<p>返回值是 渲染后的节点标题</p>
</div>
<h3>setting & function 举例</h3>
<pre xmlns=""><code>
var setting = {
data: {
render: function(title,treeNode){
return title + treeNode.id;
}
}
};
......</code></pre>
</div>
</div>
<div class="apiDetail">
<div>
<h2>
<span>Function(name, treeNode)</span
><span class="path">setting.data.render.</span>name
</h2>
<h3>
Overview<span class="h3_info"
>[ depends on <span class="highlight_green">jquery.ztree.core</span> js
]</span
>
</h3>
<div class="desc">
<p></p>
<div class="longdesc">
<p>Used to dynamically render node name using custom methods</p>
<p>Default: null</p>
<p class="highlight_red">v3.5.45+</p>
</div>
</div>
<h3>Function Parameter Descriptions</h3>
<div class="desc">
<h4><b>name</b><span>String</span></h4>
<p>Node name obtained by setting.key.name</p>
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<p>JSON data object of the target node</p>
<p class="highlight_red">When will render the root, treeNode = null</p>
<h4 class="topLine"><b>Return</b><span>Boolean</span></h4>
<p>Return the name of the node you need to display</p>
</div>
<h3>Examples of setting & function</h3>
<pre xmlns=""><code>
var setting = {
data: {
render: function(name,treeNode){
return name + treeNode.id;
}
}
};
......</code></pre>
</div>
</div>
<div class="apiDetail">
<div>
<h2>
<span>Function(title, treeNode)</span
><span class="path">setting.data.render.</span>title
</h2>
<h3>
Overview<span class="h3_info"
>[ depends on <span class="highlight_green">jquery.ztree.core</span> js
]</span
>
</h3>
<div class="desc">
<p></p>
<div class="longdesc">
<p>Used to dynamically render node title using custom methods</p>
<p>Default: null</p>
<p class="highlight_red">v3.5.45+</p>
</div>
</div>
<h3>Function Parameter Descriptions</h3>
<div class="desc">
<h4><b>title</b><span>String</span></h4>
<p>Node title obtained by setting.key.title</p>
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<p>JSON data object of the target node</p>
<p class="highlight_red">When will render the root, treeNode = null</p>
<h4 class="topLine"><b>Return</b><span>Boolean</span></h4>
<p>Return the title of the node you need to display</p>
</div>
<h3>Examples of setting & function</h3>
<pre xmlns=""><code>
var setting = {
data: {
render: function(title,treeNode){
return title + treeNode.id;
}
}
};
......</code></pre>
</div>
</div>
/* /*
* JQuery zTree core * JQuery zTree core
* v3.5.44 * v3.5.45
* http://treejs.cn/ * http://treejs.cn/
* *
* Copyright (c) 2010 Hunter.z * Copyright (c) 2010 Hunter.z
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Licensed same as jquery - MIT License * Licensed same as jquery - MIT License
* http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/mit-license.php
* *
* Date: 2020-04-29 * Date: 2020-11-03
*/ */
(function ($) { (function ($) {
...@@ -84,6 +84,10 @@ ...@@ -84,6 +84,10 @@
url: "url", url: "url",
icon: "icon" icon: "icon"
}, },
render: {
name: null,
title: null,
},
simpleData: { simpleData: {
enable: false, enable: false,
idKey: "id", idKey: "id",
...@@ -646,11 +650,19 @@ ...@@ -646,11 +650,19 @@
if (typeof newName !== 'undefined') { if (typeof newName !== 'undefined') {
node[key] = newName; node[key] = newName;
} }
return "" + node[key]; var rawName = "" + node[key];
if(typeof setting.data.render.name === 'function') {
return setting.data.render.name.call(this,rawName,node);
}
return rawName;
}, },
nodeTitle: function (setting, node) { nodeTitle: function (setting, node) {
var t = setting.data.key.title === "" ? setting.data.key.name : setting.data.key.title; var t = setting.data.key.title === "" ? setting.data.key.name : setting.data.key.title;
return "" + node[t]; var rawTitle = "" + node[t];
if(typeof setting.data.render.title === 'function') {
return setting.data.render.title.call(this,rawTitle,node);
}
return rawTitle;
}, },
removeNodeCache: function (setting, node) { removeNodeCache: function (setting, node) {
var children = data.nodeChildren(setting, node); var children = data.nodeChildren(setting, node);
...@@ -2006,7 +2018,7 @@ ...@@ -2006,7 +2018,7 @@
})(jQuery); })(jQuery);
/* /*
* JQuery zTree excheck * JQuery zTree excheck
* v3.5.44 * v3.5.45
* http://treejs.cn/ * http://treejs.cn/
* *
* Copyright (c) 2010 Hunter.z * Copyright (c) 2010 Hunter.z
...@@ -2014,7 +2026,7 @@ ...@@ -2014,7 +2026,7 @@
* Licensed same as jquery - MIT License * Licensed same as jquery - MIT License
* http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/mit-license.php
* *
* Date: 2020-04-29 * Date: 2020-11-03
*/ */
(function ($) { (function ($) {
...@@ -2658,7 +2670,7 @@ ...@@ -2658,7 +2670,7 @@
})(jQuery); })(jQuery);
/* /*
* JQuery zTree exedit * JQuery zTree exedit
* v3.5.44 * v3.5.45
* http://treejs.cn/ * http://treejs.cn/
* *
* Copyright (c) 2010 Hunter.z * Copyright (c) 2010 Hunter.z
...@@ -2666,7 +2678,7 @@ ...@@ -2666,7 +2678,7 @@
* Licensed same as jquery - MIT License * Licensed same as jquery - MIT License
* http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/mit-license.php
* *
* Date: 2020-04-29 * Date: 2020-11-03
*/ */
(function ($) { (function ($) {
......
此差异已折叠。
/* /*
* JQuery zTree core * JQuery zTree core
* v3.5.44 * v3.5.45
* http://treejs.cn/ * http://treejs.cn/
* *
* Copyright (c) 2010 Hunter.z * Copyright (c) 2010 Hunter.z
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Licensed same as jquery - MIT License * Licensed same as jquery - MIT License
* http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/mit-license.php
* *
* Date: 2020-04-29 * Date: 2020-11-03
*/ */
(function ($) { (function ($) {
...@@ -84,6 +84,10 @@ ...@@ -84,6 +84,10 @@
url: "url", url: "url",
icon: "icon" icon: "icon"
}, },
render: {
name: null,
title: null,
},
simpleData: { simpleData: {
enable: false, enable: false,
idKey: "id", idKey: "id",
...@@ -646,11 +650,19 @@ ...@@ -646,11 +650,19 @@
if (typeof newName !== 'undefined') { if (typeof newName !== 'undefined') {
node[key] = newName; node[key] = newName;
} }
return "" + node[key]; var rawName = "" + node[key];
if(typeof setting.data.render.name === 'function') {
return setting.data.render.name.call(this,rawName,node);
}
return rawName;
}, },
nodeTitle: function (setting, node) { nodeTitle: function (setting, node) {
var t = setting.data.key.title === "" ? setting.data.key.name : setting.data.key.title; var t = setting.data.key.title === "" ? setting.data.key.name : setting.data.key.title;
return "" + node[t]; var rawTitle = "" + node[t];
if(typeof setting.data.render.title === 'function') {
return setting.data.render.title.call(this,rawTitle,node);
}
return rawTitle;
}, },
removeNodeCache: function (setting, node) { removeNodeCache: function (setting, node) {
var children = data.nodeChildren(setting, node); var children = data.nodeChildren(setting, node);
......
此差异已折叠。
/* /*
* JQuery zTree excheck * JQuery zTree excheck
* v3.5.44 * v3.5.45
* http://treejs.cn/ * http://treejs.cn/
* *
* Copyright (c) 2010 Hunter.z * Copyright (c) 2010 Hunter.z
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Licensed same as jquery - MIT License * Licensed same as jquery - MIT License
* http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/mit-license.php
* *
* Date: 2020-04-29 * Date: 2020-11-03
*/ */
(function ($) { (function ($) {
......
/* /*
* JQuery zTree exedit * JQuery zTree exedit
* v3.5.44 * v3.5.45
* http://treejs.cn/ * http://treejs.cn/
* *
* Copyright (c) 2010 Hunter.z * Copyright (c) 2010 Hunter.z
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Licensed same as jquery - MIT License * Licensed same as jquery - MIT License
* http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/mit-license.php
* *
* Date: 2020-04-29 * Date: 2020-11-03
*/ */
(function ($) { (function ($) {
......
/* /*
* JQuery zTree exHideNodes * JQuery zTree exHideNodes
* v3.5.44 * v3.5.45
* http://treejs.cn/ * http://treejs.cn/
* *
* Copyright (c) 2010 Hunter.z * Copyright (c) 2010 Hunter.z
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Licensed same as jquery - MIT License * Licensed same as jquery - MIT License
* http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/mit-license.php
* *
* Date: 2020-04-29 * Date: 2020-11-03
*/ */
(function ($) { (function ($) {
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
</font> </font>
*2020.11.03* v3.5.45
* Support attribute('name' & 'title') dynamic rendering using custom function Thanks @imyuyu
*2020.04.29* v3.5.44 *2020.04.29* v3.5.44
* update TypeScript type definition Thanks @bseddon * update TypeScript type definition Thanks @bseddon
......
{ {
"name": "@ztree/ztree_v3", "name": "@ztree/ztree_v3",
"description": "zTree is a multi-functional 'tree plug-ins.' based on jQuery. The main advantages of zTree includes excellent performance, flexible configuration, and the combination of multiple functions.", "description": "zTree is a multi-functional 'tree plug-ins.' based on jQuery. The main advantages of zTree includes excellent performance, flexible configuration, and the combination of multiple functions.",
"version": "3.5.44", "version": "3.5.45",
"homepage": "http://www.treejs.cn/v3/main.php", "homepage": "http://www.treejs.cn/v3/main.php",
"author": "zTree (https://github.com/zTree)", "author": "zTree (https://github.com/zTree)",
"licenses": [ "licenses": [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册