layui/docs/treeTable/detail/options.md

184 lines
6.1 KiB
Markdown
Raw Normal View History

2023-04-24 08:42:47 +08:00
<table class="layui-table">
<colgroup>
<col width="150">
<col>
</colgroup>
<thead>
<tr>
<th>属性名</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>tree</td>
<td>
treeTable 组件的特定属性集,包含以下「子成员集」:
| 属性 | 描述 |
| --- | --- |
2023-05-03 21:34:35 +08:00
| [customName](#options.tree.customName) | 自定义属性名的集合 |
| [view](#options.tree.view) | 视图相关的属性集合 |
| [data](#options.tree.data) | 数据相关的属性集合 |
| [async](#options.tree.async) | 异步相关的属性集合 |
| [callback](#options.tree.callback) | 事件回调相关的属性集合 |
2023-04-24 08:42:47 +08:00
用法如下:
```js
treeTable.render({
elem: '',
tree: { // treeTable 特定属性集
customName: {},
data: {},
view: {},
async: {},
callback: {}
},
// 其他 table 属性
});
````
</td>
</tr>
<tr>
<td>tree.customName</td>
<td>
<div id="options.tree.customName" lay-pid="options" class="ws-anchor">
2023-04-24 08:42:47 +08:00
自定义属性名的集合,包含以下成员:
</div>
| 属性 | 描述 | 类型 | 默认值 |
| --- | --- | --- | --- |
| children | 自定义「子节点集合」的属性名 | string | `children` |
| isParent | 自定义「是否属于父节点」的属性名 | string | `isParent` |
| name | 自定义「节点」属性名 | string | `name` |
| id | 自定义「节点索引」属性名 | string | `id` |
| pid | 自定义「父节点索引」属性名 | string | `parentId` |
2023-05-30 09:55:48 +08:00
| icon | 自定义图标的属性名称 | string | `icon` |
2023-04-24 08:42:47 +08:00
</td>
</tr>
<tr>
<td>tree.view</td>
<td>
<div id="options.tree.view" lay-pid="options" class="ws-anchor">
2023-04-24 08:42:47 +08:00
视图相关的属性集合,包含以下成员:
</div>
| 属性 | 描述 | 类型 | 默认值 |
| --- | --- | --- | --- |
| indent | 层级缩进量 | number | `14` |
2024-05-18 11:26:38 +08:00
| flexIconClose | 自定义关闭时的折叠按钮图标 | string | - |
| flexIconOpen | 自定义打开时的折叠按钮图标 | string | - |
2023-04-24 08:42:47 +08:00
| showIcon | 是否显示节点图标 | boolean | `true` |
| icon | 自定义节点图标。若设置了该属性或数据中有该字段信息,不管打开还是关闭都以这个图标的值为准 | string | - |
| iconClose | 自定义关闭时的节点图标 | string | - |
| iconOpen | 自定义打开时的节点图标 | string | - |
2024-05-18 11:26:38 +08:00
| iconLeaf | 自定义叶子节点的图标 | string | - |
2023-04-24 08:42:47 +08:00
| showFlexIconIfNotParent | 若非父节点时,是否显示折叠图标 | boolean | `false` |
| dblClickExpand | 双击节点时,是否自动展开父节点 | boolean | `true` |
2023-06-16 09:46:20 +08:00
| expandAllDefault <sup>2.8.7+</sup> | 是否默认展开全部节点 | boolean | `false` |
2023-04-24 08:42:47 +08:00
2024-05-18 11:26:38 +08:00
自定义图标支持 HTML 字符串和图标类名。例如:
- `'<i class="i-svg-spinners-blocks-wave"></i>'`
- `'layui-icon layui-icon-addition'`
2023-04-24 08:42:47 +08:00
</td>
</tr>
<tr>
<td>tree.data</td>
<td>
<div id="options.tree.data" lay-pid="options" class="ws-anchor">
2023-04-24 08:42:47 +08:00
数据相关的属性集合,包含以下成员:
</div>
| 属性 | 描述 | 类型 | 默认值 |
| --- | --- | --- | --- |
2024-05-18 11:26:38 +08:00
| isSimpleData | 是否使用平铺数据格式(Array) | boolean | `false` |
| rootPid | 用于设置根节点的 `pid` 属性值 | string | `null` |
2023-08-30 09:52:22 +08:00
| cascade | 用于设置复选的级联方式。支持以下可选值:<ul><li><code>all</code> : 所有节点联动</li><li><code>parent</code> : 仅对父节点联动</li><li><code>children</code> : 仅对子节点联动</li><li><code>none</code> <sup>2.8.16+</sup> : 不做任何联动</li></ul> | string | `all` |
2023-04-24 08:42:47 +08:00
</td>
</tr>
<tr>
<td>tree.async</td>
<td>
<div id="options.tree.async" lay-pid="options" class="ws-anchor">
2023-04-24 08:42:47 +08:00
异步相关的属性集合,包含以下成员:
</div>
| 属性 | 描述 | 类型 | 默认值 |
| --- | --- | --- | --- |
feat: 重构 laytpl,增强对更多复杂模板结构的解析能力 (#2577) * feat: 重构 laytpl,增强对更多复杂模板结构的解析能力 * Squashed commit of the following: commit 6884f80378f7606366c73e75c45946acc5817c95 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 14:45:58 2025 +0800 release: v2.10.1 commit 8d643ad6dc910ab86a4883ffe27ca3626553f892 Merge: 5521e48c 213fe5a2 Author: corededitor <107152508+corededitor@users.noreply.github.com> Date: Wed Mar 19 14:24:50 2025 +0800 feat: Merge pull request #2566 from layui/feat/component feat: 优化 component, tabs 若干功能 commit 213fe5a2090a7aef26af71fb5a0d6dc517b9a915 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 14:15:39 2025 +0800 docs: 添加 component 文档中实验性选项标记 commit 5521e48c05cd496476729cd33c754961c78cd2ac Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 14:10:46 2025 +0800 fix: 修复 `body` 初始 `line-height` 无效的问题 (#2569) commit 8c7cf0f6069a44ce7160fb2d69549956471bd684 Author: 青崖 <33601030+bxjt123@users.noreply.github.com> Date: Wed Mar 19 14:10:08 2025 +0800 优化 checkbox 标签风格选中且禁用时的显示 (#2563) commit 23b21254d4c4be4fd7e99e17f60c991e874d22c0 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 14:04:44 2025 +0800 docs: Squashed commit of the following: commit 95a0503f415126edabefb2cc9646a59bcb0932f3 Merge: e6eb86ba 87ba4c43 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 14:03:13 2025 +0800 Merge branch 'main' into 2.x commit e6eb86bacb130fcf57b6407b0c426ca7f770b326 Author: morning-star <26325820+Sight-wcg@users.noreply.github.com> Date: Wed Mar 19 14:02:05 2025 +0800 docs(slider): 修正错别字 (#2578) commit 46f7a9783e039bdc0efded87640fdfab31209f67 Merge: df1fc4f4 c204590a Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Fri Mar 14 19:07:50 2025 +0800 Merge branch 'main' into 2.x commit df1fc4f419819317c012091691db1012d48d5800 Author: itletu <itletu@163.com> Date: Mon Mar 10 13:54:06 2025 +0800 docs: 更正 class 公共类文档错误 (#2544) | layui-border-box | 设置元素及其所有子元素均为 `box-sizing: border-box` 模型的容器 | commit 87ba4c4394884b794da84a3f1bc9ba786cf748e2 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 13:41:33 2025 +0800 docs(version): 优化 2.9.x 锚点 commit a0f533f0fdfa34dba83bfe81ffa366c051859947 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 13:37:29 2025 +0800 docs: 修复 tabs 文档示例异常问题 commit 0f0584e2edc94a6aa483f4b4136a05ed599b0fb4 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 13:35:00 2025 +0800 docs: 修复 tabs 文档中自定义事件示例重新点击 Preview 失效的问题 commit 172957d2433c3a592c387f5a9f394734b4b127c0 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 13:29:09 2025 +0800 docs: 优化文档中的用词细节 (#2571) commit 094be4ddcccbb18caa696af65083562960929437 Author: letianpailove <113023596+letianpailove@users.noreply.github.com> Date: Wed Mar 19 13:28:46 2025 +0800 fix: 更正 class 公共类文档错误 (#2562) commit 53ded26cb96009330977320b5991bbcd17468eb7 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Sun Mar 16 00:15:25 2025 +0800 fix: 优化 tabs 重载时未按照传入的 closable 正确渲染可关闭状态 commit bd892bf87effa582bf8e3655c710d52f4066b2a5 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Sun Mar 16 00:15:17 2025 +0800 feat(component): 新增 cache 原型方法,用于元素缓存操作 commit 6ccc5a453d250537117646e8f9fe751153fd91a3 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Sun Mar 16 00:14:18 2025 +0800 fix(component): 优化元素 lay-options 属性上的配置在重载时的优先级 commit 79b0a56f506b0553fa67e4ce7467a21d4d8660ce Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Sun Mar 16 00:13:55 2025 +0800 fix(component): 修复 reload 时传入的选项未正确合并的问题 * refactor(laytpl): 优化代码细节 * docs: 重写 laytpl 模块文档
2025-03-27 23:55:04 +08:00
| enable | 是否开启异步加载模式。只有开启时 `async` 的其他属性选项才有效。 **注意:** 异步加载子节点不应跟 `simpleData` 同时开启,可以是 `url+simpleData` 的方式,获取完整的简单数据进行转换。若开启异步加载模式,即表示按需异步加载子节点。 | boolean | `false` |
2023-04-24 08:42:47 +08:00
| url | 异步加载的接口,可以根据需要设置与顶层接口不同的接口,若相同可不设置该属性 | string | - |
2023-05-30 09:55:48 +08:00
| [format](#options.tree.async.format) | 用于处理异步子节点数据的回调函数,该属性优先级高于 `async.url` 属性。用法详见下文。 | function | - |
2023-04-24 08:42:47 +08:00
| type | 请求的接口类型,设置可缺省同上 | string | - |
| contentType | 提交参数的数据类型,设置可缺省同上 | string | - |
| headers | 提交请求头,设置可缺省同上 | object | - |
| where | 提交参数的数据,设置可缺省同上 | object | - |
| autoParam | 自动参数,可以根据配置项以及当前节点的数据传参,如: `['type', 'age=age', 'parentId=id']` ,那么其请求参数将包含: `{type: '父节点 type', age: '父节点 age', parentId: '父节点 id'}` | array | - |
2023-04-24 08:42:47 +08:00
2023-05-30 09:55:48 +08:00
<div id="options.tree.async.format" class="ws-anchor">
**format 示例**
</div>
```
treeTable.render({
elem: '',
tree: {
2023-05-30 09:55:48 +08:00
enable: true,
async: {
format: function(trData, options, callback){
feat: 重构 laytpl,增强对更多复杂模板结构的解析能力 (#2577) * feat: 重构 laytpl,增强对更多复杂模板结构的解析能力 * Squashed commit of the following: commit 6884f80378f7606366c73e75c45946acc5817c95 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 14:45:58 2025 +0800 release: v2.10.1 commit 8d643ad6dc910ab86a4883ffe27ca3626553f892 Merge: 5521e48c 213fe5a2 Author: corededitor <107152508+corededitor@users.noreply.github.com> Date: Wed Mar 19 14:24:50 2025 +0800 feat: Merge pull request #2566 from layui/feat/component feat: 优化 component, tabs 若干功能 commit 213fe5a2090a7aef26af71fb5a0d6dc517b9a915 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 14:15:39 2025 +0800 docs: 添加 component 文档中实验性选项标记 commit 5521e48c05cd496476729cd33c754961c78cd2ac Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 14:10:46 2025 +0800 fix: 修复 `body` 初始 `line-height` 无效的问题 (#2569) commit 8c7cf0f6069a44ce7160fb2d69549956471bd684 Author: 青崖 <33601030+bxjt123@users.noreply.github.com> Date: Wed Mar 19 14:10:08 2025 +0800 优化 checkbox 标签风格选中且禁用时的显示 (#2563) commit 23b21254d4c4be4fd7e99e17f60c991e874d22c0 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 14:04:44 2025 +0800 docs: Squashed commit of the following: commit 95a0503f415126edabefb2cc9646a59bcb0932f3 Merge: e6eb86ba 87ba4c43 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 14:03:13 2025 +0800 Merge branch 'main' into 2.x commit e6eb86bacb130fcf57b6407b0c426ca7f770b326 Author: morning-star <26325820+Sight-wcg@users.noreply.github.com> Date: Wed Mar 19 14:02:05 2025 +0800 docs(slider): 修正错别字 (#2578) commit 46f7a9783e039bdc0efded87640fdfab31209f67 Merge: df1fc4f4 c204590a Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Fri Mar 14 19:07:50 2025 +0800 Merge branch 'main' into 2.x commit df1fc4f419819317c012091691db1012d48d5800 Author: itletu <itletu@163.com> Date: Mon Mar 10 13:54:06 2025 +0800 docs: 更正 class 公共类文档错误 (#2544) | layui-border-box | 设置元素及其所有子元素均为 `box-sizing: border-box` 模型的容器 | commit 87ba4c4394884b794da84a3f1bc9ba786cf748e2 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 13:41:33 2025 +0800 docs(version): 优化 2.9.x 锚点 commit a0f533f0fdfa34dba83bfe81ffa366c051859947 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 13:37:29 2025 +0800 docs: 修复 tabs 文档示例异常问题 commit 0f0584e2edc94a6aa483f4b4136a05ed599b0fb4 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 13:35:00 2025 +0800 docs: 修复 tabs 文档中自定义事件示例重新点击 Preview 失效的问题 commit 172957d2433c3a592c387f5a9f394734b4b127c0 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Wed Mar 19 13:29:09 2025 +0800 docs: 优化文档中的用词细节 (#2571) commit 094be4ddcccbb18caa696af65083562960929437 Author: letianpailove <113023596+letianpailove@users.noreply.github.com> Date: Wed Mar 19 13:28:46 2025 +0800 fix: 更正 class 公共类文档错误 (#2562) commit 53ded26cb96009330977320b5991bbcd17468eb7 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Sun Mar 16 00:15:25 2025 +0800 fix: 优化 tabs 重载时未按照传入的 closable 正确渲染可关闭状态 commit bd892bf87effa582bf8e3655c710d52f4066b2a5 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Sun Mar 16 00:15:17 2025 +0800 feat(component): 新增 cache 原型方法,用于元素缓存操作 commit 6ccc5a453d250537117646e8f9fe751153fd91a3 Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Sun Mar 16 00:14:18 2025 +0800 fix(component): 优化元素 lay-options 属性上的配置在重载时的优先级 commit 79b0a56f506b0553fa67e4ce7467a21d4d8660ce Author: 贤心 <3277200+sentsim@users.noreply.github.com> Date: Sun Mar 16 00:13:55 2025 +0800 fix(component): 修复 reload 时传入的选项未正确合并的问题 * refactor(laytpl): 优化代码细节 * docs: 重写 laytpl 模块文档
2025-03-27 23:55:04 +08:00
// trData 为行数据、options 为 treeTable 属性选项
2023-05-30 09:55:48 +08:00
// callbacck 为子节点的渲染函数
// 可利用该函数对子节点数据进行异步请求或其他格式化处理
var nodeList = [
{id: 111, name: '子节点1'},
{id: 333, name: '子节点3'}
];
callback(nodeList);
}
}
}
})
```
2023-04-24 08:42:47 +08:00
</td>
</tr>
<tr>
<td>tree.callback</td>
<td>
<div id="options.tree.callback" lay-pid="options" class="ws-anchor">
2023-04-24 08:42:47 +08:00
事件回调相关的属性集合,包含以下成员:
</div>
| 属性 | 描述 |
| --- | --- |
| beforeExpand | 展开前回调函数。可以在展开或者关闭之前调用,传入当前表格 `id` ,当前操作的行数据以及要展开或关闭的状态,若回调返回 `false` 则取消该次操作。 返回的参数包含: `function(tableId, trData, expandFlag){ console.log(arguments); }` |
| onExpand | 展开或关闭后的回调函数,返回参数同 `beforeExpand` |
</td>
</tr>
</tbody>
2023-08-30 09:52:22 +08:00
</table>