mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-12-01 03:38:30 +08:00
Table: update sorting docs (#5364)
This commit is contained in:
parent
28fafaf832
commit
7a29401485
@ -69,17 +69,19 @@
|
|||||||
|
|
||||||
p {
|
p {
|
||||||
margin: 0 0 12px;
|
margin: 0 0 12px;
|
||||||
|
line-height: 1.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
color: #5e6d82;
|
color: #5e6d82;
|
||||||
background-color: #e6effb;
|
background-color: #e6effb;
|
||||||
margin: 0 4px;
|
margin: 0 4px;
|
||||||
transform: translateY(-2px);
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 1px 5px;
|
padding: 1px 5px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
height: 18px;
|
||||||
|
line-height: 18px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1239,7 +1239,7 @@ You can also select multiple rows.
|
|||||||
|
|
||||||
Sort the data to find or compare data quickly.
|
Sort the data to find or compare data quickly.
|
||||||
|
|
||||||
:::demo Set table attribute `default-sort` to determine default sort column and order. Set attribute `sortable` in a certain column to sort the data based on this column. It accepts `Boolean` with a default value `false`. In this example we use another attribute named `formatter` to format the value of certain columns. It accepts a function which has two parameters: `row` and `column`. You can handle it according to your own needs.
|
:::demo Set attribute `sortable` in a certain column to sort the data based on this column. It accepts `Boolean` with a default value `false`. Set table attribute `default-sort` to determine default sort column and order. To apply your own sorting rules, use `sort-method`. If you need remote sorting from backend, set `sortable` to `custom`, and listen to the `sort-change` event on Table. In the event handler, you have access to the sorting column and sorting order so that you can fetch sorted table data from API. In this example we use another attribute named `formatter` to format the value of certain columns. It accepts a function which has two parameters: `row` and `column`. You can handle it according to your own needs.
|
||||||
```html
|
```html
|
||||||
<template>
|
<template>
|
||||||
<el-table
|
<el-table
|
||||||
@ -1757,7 +1757,7 @@ For table of numbers, you can add an extra row at the table footer displaying ea
|
|||||||
| min-width | column minimum width. Columns with `width` has a fixed width, while columns with `min-width` has a width that is distributed in proportion | string | — | — |
|
| min-width | column minimum width. Columns with `width` has a fixed width, while columns with `min-width` has a width that is distributed in proportion | string | — | — |
|
||||||
| fixed | whether column is fixed at left/right. Will be fixed at left if `true` | string/boolean | true/left/right | — |
|
| fixed | whether column is fixed at left/right. Will be fixed at left if `true` | string/boolean | true/left/right | — |
|
||||||
| render-header | render function for table header of this column | Function(h, { column, $index }) | — | — |
|
| render-header | render function for table header of this column | Function(h, { column, $index }) | — | — |
|
||||||
| sortable | whether column can be sorted | boolean | — | false |
|
| sortable | whether column can be sorted. Remote sorting can be done by setting this attribute to 'custom' and listening to the `sort-change` event of Table | boolean, string | true, false, custom | false |
|
||||||
| sort-method | sorting method, works when `sortable` is `true`. Should return a boolean. | Function(a, b) | — | — |
|
| sort-method | sorting method, works when `sortable` is `true`. Should return a boolean. | Function(a, b) | — | — |
|
||||||
| resizable | whether column width can be resized, works when `border` of `el-table` is `true` | boolean | — | false |
|
| resizable | whether column width can be resized, works when `border` of `el-table` is `true` | boolean | — | false |
|
||||||
| formatter | function that formats content | Function(row, column) | — | — |
|
| formatter | function that formats content | Function(row, column) | — | — |
|
||||||
|
@ -1277,7 +1277,7 @@
|
|||||||
|
|
||||||
对表格进行排序,可快速查找或对比数据。
|
对表格进行排序,可快速查找或对比数据。
|
||||||
|
|
||||||
:::demo 可以通过表的`default-sort`属性设置默认的排序列和排序顺序。在列中设置`sortable`属性即可实现以该列为基准的排序,接受一个`Boolean`,默认为`false`。在本例中,我们还使用了`formatter`属性,它用于格式化指定列的值,接受一个`Function`,会传入两个参数:`row`和`column`,可以根据自己的需求进行处理。
|
:::demo 在列中设置`sortable`属性即可实现以该列为基准的排序,接受一个`Boolean`,默认为`false`。可以通过 Table 的`default-sort`属性设置默认的排序列和排序顺序。可以使用`sort-method`使用自定义的排序规则。如果需要后端排序,需将`sortable`设置为`custom`,同时在 Table 上监听`sort-change`事件,在事件回调中可以获取当前排序的字段名和排序顺序,从而向接口请求排序后的表格数据。在本例中,我们还使用了`formatter`属性,它用于格式化指定列的值,接受一个`Function`,会传入两个参数:`row`和`column`,可以根据自己的需求进行处理。
|
||||||
```html
|
```html
|
||||||
<template>
|
<template>
|
||||||
<el-table
|
<el-table
|
||||||
|
Loading…
Reference in New Issue
Block a user