Skip to content

Commit 60796de

Browse files
author
zTreeAPI
committed
* Support attribute('name' & 'title') dynamic rendering using custom function Thanks @imyuyu
1 parent 8e75119 commit 60796de

17 files changed

+193
-73
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
jQuery Tree Plugin ---- zTree
22
============
3-
last verson : 3.5.44
3+
last verson : 3.5.45
44

55

66
**Donate to zTree** : http://www.treejs.cn/v3/donate.php
77

8+
89
zTree API : http://www.treejs.cn/v3/api.php
910

11+
1012
zTree Demo : http://www.treejs.cn/v3/demo.php
1113

14+
1215
Install
1316
============
1417
```

api/API_cn.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<div class="ieSuggest">浏览本网站建议您使用 Chrome、FireFox、Opera、IE9 等浏览器(只要不是 IE6 7 8 就行), 速度会更快,画面会更炫!</div>
3636
<div class="google_plus"><g:plusone></g:plusone></div>
3737
<div class="header-text">
38-
<h1><em>zTree v3.5.44 API 文档</em></h1><p></p>
38+
<h1><em>zTree v3.5.45 API 文档</em></h1><p></p>
3939
<p>all.js = core + excheck + exedit ( 不包括 exhide ); 发现错误请及时通知,谢谢。</p>
4040
</div>
4141
<ul class="shortcuts language" style="top:0;">

api/API_en.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<div class="ieSuggest">If you use the Chrome / FireFox / Opera / IE9 browser will be even more dazzling effect!</div>
3535
<div class="google_plus"><g:plusone></g:plusone></div>
3636
<div class="header-text">
37-
<h1><em>zTree v3.5.44 API Document</em></h1><p></p>
37+
<h1><em>zTree v3.5.45 API Document</em></h1><p></p>
3838
<p>all.js = core + excheck + exedit ( without exhide ); if you found some mistakes please contact me.</p>
3939
</div>
4040
<ul class="shortcuts language" style="top:0;">

api/apiCss/jquery.ztree.core.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
<div class="apiDetail">
2-
<div>
3-
<h2><span>Function(name, treeNode)</span><span class="path">setting.data.render.</span>name</h2>
4-
<h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 核心 js ]</span></h3>
5-
<div class="desc">
6-
<p></p>
7-
<div class="longdesc">
8-
<p>用于渲染节点名称时进行重新渲染节点名称,最终节点名称将以方法返回的值为准</p>
9-
<p>默认值:null</p>
10-
</div>
11-
</div>
12-
<h3>Function 参数说明</h3>
13-
<div class="desc">
14-
<h4><b>name</b><span>String</span></h4>
15-
<p>对应 zTree 利用 setting.key.name 获取到的节点名称 </p>
16-
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
17-
<p>待渲染节点的 JSON 数据对象</p>
18-
<p class="highlight_red">针对根进行渲染时,treeNode = null</p>
19-
<h4 class="topLine"><b>返回值</b><span>Boolean</span></h4>
20-
<p>返回值是 渲染后的节点名称</p>
21-
</div>
22-
<h3>setting & function 举例</h3>
23-
<pre xmlns=""><code>
2+
<div>
3+
<h2>
4+
<span>Function(name, treeNode)</span
5+
><span class="path">setting.data.render.</span>name
6+
</h2>
7+
<h3>
8+
概述<span class="h3_info"
9+
>[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 核心 js
10+
]</span
11+
>
12+
</h3>
13+
<div class="desc">
14+
<p></p>
15+
<div class="longdesc">
16+
<p>用于使用自定义的方法动态渲染节点名称</p>
17+
<p>默认值:null</p>
18+
<p class="highlight_red">v3.5.45+</p>
19+
</div>
20+
</div>
21+
<h3>Function 参数说明</h3>
22+
<div class="desc">
23+
<h4><b>name</b><span>String</span></h4>
24+
<p>对应 zTree 利用 setting.key.name 获取到的节点名称</p>
25+
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
26+
<p>待渲染节点的 JSON 数据对象</p>
27+
<p class="highlight_red">针对根进行渲染时,treeNode = null</p>
28+
<h4 class="topLine"><b>返回值</b><span>Boolean</span></h4>
29+
<p>返回值是 渲染后的节点名称</p>
30+
</div>
31+
<h3>setting & function 举例</h3>
32+
<pre xmlns=""><code>
2433
var setting = {
2534
data: {
2635
render: function(name,treeNode){
@@ -29,5 +38,5 @@ <h3>setting & function 举例</h3>
2938
}
3039
};
3140
......</code></pre>
32-
</div>
33-
</div>
41+
</div>
42+
</div>
Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
<div class="apiDetail">
2-
<div>
3-
<h2><span>Function(title, treeNode)</span><span class="path">setting.data.render.</span>title</h2>
4-
<h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 核心 js ]</span></h3>
5-
<div class="desc">
6-
<p></p>
7-
<div class="longdesc">
8-
<p>用于渲染节点标题时进行重新渲染节点标题,最终节点标题将以方法返回的值为准</p>
9-
<p>默认值:null</p>
10-
</div>
11-
</div>
12-
<h3>Function 参数说明</h3>
13-
<div class="desc">
14-
<h4><b>title</b><span>String</span></h4>
15-
<p>对应 zTree 利用 setting.key.title 获取到的节点标题 </p>
16-
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
17-
<p>待渲染节点的 JSON 数据对象</p>
18-
<p class="highlight_red">针对根进行渲染时,treeNode = null</p>
19-
<h4 class="topLine"><b>返回值</b><span>Boolean</span></h4>
20-
<p>返回值是 渲染后的节点标题</p>
21-
</div>
22-
<h3>setting & function 举例</h3>
23-
<pre xmlns=""><code>
2+
<div>
3+
<h2>
4+
<span>Function(title, treeNode)</span
5+
><span class="path">setting.data.render.</span>title
6+
</h2>
7+
<h3>
8+
概述<span class="h3_info"
9+
>[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 核心 js
10+
]</span
11+
>
12+
</h3>
13+
<div class="desc">
14+
<p></p>
15+
<div class="longdesc">
16+
<p>用于使用自定义的方法动态渲染节点标题</p>
17+
<p>默认值:null</p>
18+
<p class="highlight_red">v3.5.45+</p>
19+
</div>
20+
</div>
21+
<h3>Function 参数说明</h3>
22+
<div class="desc">
23+
<h4><b>title</b><span>String</span></h4>
24+
<p>对应 zTree 利用 setting.key.title 获取到的节点标题</p>
25+
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
26+
<p>待渲染节点的 JSON 数据对象</p>
27+
<p class="highlight_red">针对根进行渲染时,treeNode = null</p>
28+
<h4 class="topLine"><b>返回值</b><span>Boolean</span></h4>
29+
<p>返回值是 渲染后的节点标题</p>
30+
</div>
31+
<h3>setting & function 举例</h3>
32+
<pre xmlns=""><code>
2433
var setting = {
2534
data: {
2635
render: function(title,treeNode){
@@ -29,5 +38,5 @@ <h3>setting & function 举例</h3>
2938
}
3039
};
3140
......</code></pre>
32-
</div>
33-
</div>
41+
</div>
42+
</div>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<div class="apiDetail">
2+
<div>
3+
<h2>
4+
<span>Function(name, treeNode)</span
5+
><span class="path">setting.data.render.</span>name
6+
</h2>
7+
<h3>
8+
Overview<span class="h3_info"
9+
>[ depends on <span class="highlight_green">jquery.ztree.core</span> js
10+
]</span
11+
>
12+
</h3>
13+
<div class="desc">
14+
<p></p>
15+
<div class="longdesc">
16+
<p>Used to dynamically render node name using custom methods</p>
17+
<p>Default: null</p>
18+
<p class="highlight_red">v3.5.45+</p>
19+
</div>
20+
</div>
21+
<h3>Function Parameter Descriptions</h3>
22+
<div class="desc">
23+
<h4><b>name</b><span>String</span></h4>
24+
<p>Node name obtained by setting.key.name</p>
25+
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
26+
<p>JSON data object of the target node</p>
27+
<p class="highlight_red">When will render the root, treeNode = null</p>
28+
<h4 class="topLine"><b>Return</b><span>Boolean</span></h4>
29+
<p>Return the name of the node you need to display</p>
30+
</div>
31+
<h3>Examples of setting & function</h3>
32+
<pre xmlns=""><code>
33+
var setting = {
34+
data: {
35+
render: function(name,treeNode){
36+
return name + treeNode.id;
37+
}
38+
}
39+
};
40+
......</code></pre>
41+
</div>
42+
</div>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<div class="apiDetail">
2+
<div>
3+
<h2>
4+
<span>Function(title, treeNode)</span
5+
><span class="path">setting.data.render.</span>title
6+
</h2>
7+
<h3>
8+
Overview<span class="h3_info"
9+
>[ depends on <span class="highlight_green">jquery.ztree.core</span> js
10+
]</span
11+
>
12+
</h3>
13+
<div class="desc">
14+
<p></p>
15+
<div class="longdesc">
16+
<p>Used to dynamically render node title using custom methods</p>
17+
<p>Default: null</p>
18+
<p class="highlight_red">v3.5.45+</p>
19+
</div>
20+
</div>
21+
<h3>Function Parameter Descriptions</h3>
22+
<div class="desc">
23+
<h4><b>title</b><span>String</span></h4>
24+
<p>Node title obtained by setting.key.title</p>
25+
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
26+
<p>JSON data object of the target node</p>
27+
<p class="highlight_red">When will render the root, treeNode = null</p>
28+
<h4 class="topLine"><b>Return</b><span>Boolean</span></h4>
29+
<p>Return the title of the node you need to display</p>
30+
</div>
31+
<h3>Examples of setting & function</h3>
32+
<pre xmlns=""><code>
33+
var setting = {
34+
data: {
35+
render: function(title,treeNode){
36+
return title + treeNode.id;
37+
}
38+
}
39+
};
40+
......</code></pre>
41+
</div>
42+
</div>

js/jquery.ztree.all.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
22
* JQuery zTree core
3-
* v3.5.44
3+
* v3.5.45
44
* http://treejs.cn/
55
*
66
* Copyright (c) 2010 Hunter.z
77
*
88
* Licensed same as jquery - MIT License
99
* http://www.opensource.org/licenses/mit-license.php
1010
*
11-
* Date: 2020-04-29
11+
* Date: 2020-11-03
1212
*/
1313

1414
(function ($) {
@@ -84,6 +84,10 @@
8484
url: "url",
8585
icon: "icon"
8686
},
87+
render: {
88+
name: null,
89+
title: null,
90+
},
8791
simpleData: {
8892
enable: false,
8993
idKey: "id",
@@ -646,11 +650,19 @@
646650
if (typeof newName !== 'undefined') {
647651
node[key] = newName;
648652
}
649-
return "" + node[key];
653+
var rawName = "" + node[key];
654+
if(typeof setting.data.render.name === 'function') {
655+
return setting.data.render.name.call(this,rawName,node);
656+
}
657+
return rawName;
650658
},
651659
nodeTitle: function (setting, node) {
652660
var t = setting.data.key.title === "" ? setting.data.key.name : setting.data.key.title;
653-
return "" + node[t];
661+
var rawTitle = "" + node[t];
662+
if(typeof setting.data.render.title === 'function') {
663+
return setting.data.render.title.call(this,rawTitle,node);
664+
}
665+
return rawTitle;
654666
},
655667
removeNodeCache: function (setting, node) {
656668
var children = data.nodeChildren(setting, node);
@@ -2006,15 +2018,15 @@
20062018
})(jQuery);
20072019
/*
20082020
* JQuery zTree excheck
2009-
* v3.5.44
2021+
* v3.5.45
20102022
* http://treejs.cn/
20112023
*
20122024
* Copyright (c) 2010 Hunter.z
20132025
*
20142026
* Licensed same as jquery - MIT License
20152027
* http://www.opensource.org/licenses/mit-license.php
20162028
*
2017-
* Date: 2020-04-29
2029+
* Date: 2020-11-03
20182030
*/
20192031

20202032
(function ($) {
@@ -2658,15 +2670,15 @@
26582670
})(jQuery);
26592671
/*
26602672
* JQuery zTree exedit
2661-
* v3.5.44
2673+
* v3.5.45
26622674
* http://treejs.cn/
26632675
*
26642676
* Copyright (c) 2010 Hunter.z
26652677
*
26662678
* Licensed same as jquery - MIT License
26672679
* http://www.opensource.org/licenses/mit-license.php
26682680
*
2669-
* Date: 2020-04-29
2681+
* Date: 2020-11-03
26702682
*/
26712683

26722684
(function ($) {

js/jquery.ztree.all.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)