mirror of https://github.com/layui/layui
丰富 table 文档关于 `renderData` 方法的介绍
parent
ff40094eb6
commit
1b8a033557
|
@ -20,11 +20,12 @@ toc: true
|
|||
| API | 描述 |
|
||||
| --- | --- |
|
||||
| var table = layui.table | 获得 `table` 模块。 |
|
||||
| [table.set(options)](#set) | 设定全局默认属性项 |
|
||||
| [table.set(options)](#set) | 设定全局默认属性项。 |
|
||||
| [table.render(options)](#render) | table 组件渲染,核心方法。 |
|
||||
| [table.init(filter, options)](#table.init) | 初始化渲染静态表格。 |
|
||||
| [table.reload(id, options, deep)](#table.reload) | 表格完整重载。 |
|
||||
| [table.reloadData(id, options, deep)](#table.reloadData) <sup>2.7+</sup> | 表格数据重载。 |
|
||||
| [table.renderData(id)](#table.renderData) <sup>2.8.5+</sup> | 重新渲染数据。 |
|
||||
| [table.checkStatus(id)](#table.checkStatus) | 获取选中行相关数据。 |
|
||||
| [table.setRowChecked(id, opts)](#table.setRowChecked) <sup>2.8+</sup> | 设置行选中状态。 |
|
||||
| [table.getData(id)](#table.getData) | 获取当前页所有行表格数据。 |
|
||||
|
@ -286,6 +287,31 @@ table.reloadData('test', {
|
|||
});
|
||||
```
|
||||
|
||||
<h3 id="table.renderData" lay-pid="api" class="ws-anchor ws-bold">重新渲染数据 <sup>2.8.5+</sup></h3>
|
||||
|
||||
`table.renderData(id);`
|
||||
- 参数 `id` : table 渲染时的 `id` 属性值
|
||||
|
||||
该方法用于重新渲染数据,一般在修改 `table.cache` 后使用。
|
||||
|
||||
```js
|
||||
// 渲染
|
||||
table.render({
|
||||
elem: '', // 绑定元素选择器
|
||||
id: 'test', // 自定义 id 索引
|
||||
// 其他属性 …
|
||||
});
|
||||
// 获取当前实例的数据缓存
|
||||
var data = table.cache['test'];
|
||||
// 获取某行数据,并从 data 中移除该行
|
||||
var item = data.splice(index, 1) // index 为当前行下标,一般可在事件中通过 obj.index 得到
|
||||
// 将某行数据移动到另外某行
|
||||
data.splice(newIndex, 0, item[0]);
|
||||
// 根据 table.cache 重新渲染数据
|
||||
table.renderData('test');
|
||||
```
|
||||
|
||||
|
||||
<h3 id="table.checkStatus" lay-pid="api" class="ws-anchor ws-bold">获取选中行</h3>
|
||||
|
||||
`table.checkStatus(id);`
|
||||
|
|
Loading…
Reference in New Issue