diff --git a/components/table/demo/head.vue b/components/table/demo/head.vue index 6b829f850..195aef538 100644 --- a/components/table/demo/head.vue +++ b/components/table/demo/head.vue @@ -9,18 +9,24 @@ title: ## zh-CN 对某一列数据进行筛选,使用列的 `filters` 属性来指定需要筛选菜单的列,`onFilter` 用于筛选当前数据,`filterMultiple` 用于指定多选和单选。 -对某一列数据进行排序,通过指定列的 `sorter` 函数即可启动排序按钮。`sorter: function(rowA, rowB) { ... }`, rowA、rowB 为比较的两个行数据。 -`sortDirections: ['ascend' | 'descend']`改变每列可用的排序方式,切换排序时按数组内容依次切换,设置在 table props 上时对所有列生效。 -使用 `defaultSortOrder` 属性,设置列的默认排序顺序。 +使用 `default-filtered-value` 属性,设置列的默认筛选项。 +对某一列数据进行排序,通过指定列的 `sorter` 函数即可启用排序按钮。`sorter: function(rowA, rowB) { ... }`,其中 `rowA`、`rowB` 为待比较的两行数据。 +如果指定了 sortOrder 或 defaultSortOrder(值为 'ascend' 或 'descend'),该排序方向会作为第三个参数传入 sorter 函数,此时函数可写为: `function(rowA, rowB, sortOrder) { ... }`。 +通过 `sort-directions` 属性可自定义排序切换顺序。该属性接受一个数组,切换排序时将按数组元素依次循环。当设置在 table props 上时,对所有列生效。 +> 默认值:`['ascend', 'descend']`。 +> 若需禁止恢复到“无排序”状态,可设为:`['ascend', 'descend', 'ascend']`。 ## en-US -Use `filters` to generate filter menu in columns, `onFilter` to determine filtered result, and `filterMultiple` to indicate whether it's multiple or single selection. -Uses `defaultFilteredValue` to make a column filtered by default. -Use `sorter` to make a column sortable. `sorter` can be a function of the type `function(a, b) { ... }` for sorting data locally. -`sortDirections: ['ascend' | 'descend']` defines available sort methods for each columns, effective for all columns when set on table props. -Uses `defaultSortOrder` to make a column sorted by default. -If a `sortOrder` or `defaultSortOrder` is specified with the value `ascend` or `descend`, you can access this value from within the function passed to the `sorter` as explained above. Such a function can take the form: `function(a, b, sortOrder) { ... }`. +Use `filters` to specify the filter menu options for a column, `onFilter` to determine how the current data is filtered, and `filterMultiple` to indicate whether multiple or single selection is allowed. +Use `defaultFilteredValue` to apply a default filter to a column on initial render. +Use `sorter` to enable sorting for a column—the sort button will appear automatically when a `sorter` function is provided. +Use `defaultSortOrder` to apply an initial sort direction (`'ascend'` or `'descend'`) to a column on first render. +The `sorter` can be a function of the type `function(rowA, rowB) { ... }` for local sorting, where `rowA` and `rowB` are the two row records being compared. +If a `sortOrder` or `defaultSortOrder` is specified with the value `'ascend'` or `'descend'`, this value is passed as a third argument to the `sorter` function, which can then take the form: `function(rowA, rowB, sortOrder) { ... }`. +`sortDirections` defines the sorting cycle order for each column. Clicking the sort button cycles through the values in the array sequentially. When set on the table props, it applies to all columns. +> Default value: `['ascend', 'descend']`. +> To prevent returning to an unsorted state, set it to: `['ascend', 'descend', 'ascend']`.