Skip to content

Commit 3e704f9

Browse files
committed
feat: update table
1 parent e411d42 commit 3e704f9

File tree

12 files changed

+162
-118
lines changed

12 files changed

+162
-118
lines changed

components/table/Table.jsx

Lines changed: 126 additions & 73 deletions
Large diffs are not rendered by default.

components/table/demo/basic.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ Simple table with actions.
1414
<a slot="name" slot-scope="text" href="javascript:;">{{text}}</a>
1515
<span slot="customTitle"><a-icon type="smile-o" /> Name</span>
1616
<span slot="tags" slot-scope="tags">
17-
<a-tag v-for="tag in tags" color="blue" :key="tag">{{tag}}</a-tag>
17+
<a-tag
18+
v-for="tag in tags"
19+
:color="tag==='loser' ? 'volcano' : (tag.length > 5 ? 'geekblue' : 'green')"
20+
:key="tag"
21+
>
22+
{{tag.toUpperCase()}}
23+
</a-tag>
1824
</span>
1925
<span slot="action" slot-scope="text, record">
2026
<a href="javascript:;">Invite 一 {{record.name}}</a>

components/table/demo/custom-filter-panel.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Implement a customized column search example via `filterDropdown`.
1111
```html
1212
<template>
1313
<a-table :dataSource="data" :columns="columns">
14-
<div slot="filterDropdown" slot-scope="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }" class='custom-filter-dropdown'>
14+
<div slot="filterDropdown" slot-scope="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }" style="padding: 8px">
1515
<a-input
1616
v-ant-ref="c => searchInput = c"
1717
:placeholder="`Search ${column.dataIndex}`"
@@ -143,12 +143,6 @@ export default {
143143
}
144144
</script>
145145
<style scoped>
146-
.custom-filter-dropdown {
147-
padding: 8px;
148-
border-radius: 4px;
149-
background: #fff;
150-
box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
151-
}
152146
153147
.highlight {
154148
background-color: rgb(255, 192, 105);

components/table/demo/fixed-columns-header.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<cn>
22
#### 固定头和列
33
适合同时展示有大量数据和数据列。
4-
> 若列头与内容不对齐或出现列重复,请指定列的宽度 `width`
4+
> 若列头与内容不对齐或出现列重复,请指定**固定列**的宽度 `width`
55
> 建议指定 `scroll.x` 为大于表格宽度的固定值或百分比。注意,且非固定列宽度之和不要超过 `scroll.x`
66
</cn>
77
88
<us>
99
#### Fixed Columns and Header
1010
A Solution for displaying large amounts of data with long columns.
11-
> Specify the width of columns if header and cell do not align properly.
11+
> Specify the width of columns if header and cell do not align properly. (Leave one column at least without width to fit fluid layout)
1212
> A fixed value which is greater than table width for `scroll.x` is recommended. The sum of unfixed columns should not greater than `scroll.x`.
1313
</us>
1414

components/table/demo/fixed-columns.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<cn>
22
#### 固定列
33
对于列数很多的数据,可以固定前后的列,横向滚动查看其它数据,需要和 `scroll.x` 配合使用。
4-
> 若列头与内容不对齐或出现列重复,请指定列的宽度 `width`
4+
> 若列头与内容不对齐或出现列重复,请指定**固定列**的宽度 `width`
55
> 建议指定 `scroll.x` 为大于表格宽度的固定值或百分比。注意,且非固定列宽度之和不要超过 `scroll.x`
66
</cn>
77
88
<us>
99
#### Fixed Columns
1010
To fix some columns and scroll inside other columns, and you must set `scroll.x` meanwhile.
11-
> Specify the width of columns if header and cell do not align properly.
11+
> Specify the width of columns if header and cell do not align properly.(Leave one column at least without width to fit fluid layout)
1212
> A fixed value which is greater than table width for `scroll.x` is recommended. The sum of unfixed columns should not greater than `scroll.x`.
1313
</us>
1414

components/table/demo/fixed-header.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<cn>
22
#### 固定表头
33
方便一页内展示大量数据。
4-
需要指定 column 的 `width` 属性,否则列头和内容可能不对齐。
4+
需要指定 column 的 `width` 属性,否则列头和内容可能不对齐。(建议留一列不设宽度以适应弹性布局)
55
</cn>
66

77
<us>
88
#### Fixed Header
99
Display large amounts of data in scrollable view.
10-
> Specify the width of each column if header and cell do not align properly.
10+
> Specify width of columns if header and cell do not align properly.(Leave one column at least without width to fit fluid layout)
1111
</us>
1212
1313
```html

components/table/demo/head.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
#### 筛选和排序
33
对某一列数据进行筛选,使用列的 `filters` 属性来指定需要筛选菜单的列,`onFilter` 用于筛选当前数据,`filterMultiple` 用于指定多选和单选。
44
对某一列数据进行排序,通过指定列的 `sorter` 函数即可启动排序按钮。`sorter: function(rowA, rowB) { ... }`, rowA、rowB 为比较的两个行数据。
5+
`sortDirections: ['ascend' | 'descend']`改变每列可用的排序方式,切换排序时按数组内容依次切换,设置在table props上时对所有列生效。
56
使用 `defaultSortOrder` 属性,设置列的默认排序顺序。
67
</cn>
78

89
<us>
910
#### Filter and sorter
1011
Use `filters` to generate filter menu in columns, `onFilter` to determine filtered result, and `filterMultiple` to indicate whether it's multiple or single selection.
1112
Use `sorter` to make a column sortable. `sorter` can be a function of the type `function(a, b) { ... }` for sorting data locally.
13+
`sortDirections: ['ascend' | 'descend']` defines available sort methods for each columns, effective for all columns when set on table props.
1214
Uses `defaultSortOrder` to make a column sorted by default.
1315
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) { ... }`.
1416
</us>
@@ -42,6 +44,7 @@ const columns = [{
4244
// here is that finding the name started with `value`
4345
onFilter: (value, record) => record.name.indexOf(value) === 0,
4446
sorter: (a, b) => a.name.length - b.name.length,
47+
sortDirections: ['descend'],
4548
}, {
4649
title: 'Age',
4750
dataIndex: 'age',
@@ -59,6 +62,7 @@ const columns = [{
5962
filterMultiple: false,
6063
onFilter: (value, record) => record.address.indexOf(value) === 0,
6164
sorter: (a, b) => a.address.length - b.address.length,
65+
sortDirections: ['descend', 'ascend'],
6266
}];
6367
6468
const data = [{

components/table/demo/index.vue

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,8 @@ export default {
6262
return (
6363
<div>
6464
<md cn={md.cn} us={md.us}/>
65-
<Ajax />
66-
<Basic />
67-
<Bordered />
68-
<ColspanRowspan />
6965
<CustomFilterPanel />
70-
<EditCell />
71-
<EditRow />
72-
<ExpandChildren />
73-
<Expand />
74-
<FixedColumnsHeader />
75-
<FixedColumns />
76-
<FixedHeader />
77-
<GroupingColumns />
78-
<Head />
79-
<NestedTable />
80-
<ResetFilter />
81-
<RowSelectionAndOperation />
82-
<RowSelectionCustom />
83-
<RowSelection />
84-
<Size />
85-
<Template />
66+
8667
<api>
8768
<template slot='cn'>
8869
<CN/>

components/table/filterDropdown.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ export default {
261261
}
262262

263263
const menus = filterDropdown ? (
264-
<FilterDropdownMenuWrapper>{filterDropdown}</FilterDropdownMenuWrapper>
264+
<FilterDropdownMenuWrapper class={`${prefixCls}-dropdown`}>{filterDropdown}</FilterDropdownMenuWrapper>
265265
) : (
266266
<FilterDropdownMenuWrapper class={`${prefixCls}-dropdown`}>
267267
<Menu

components/table/index.en-US.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const columns = [{
5050
| indentSize | Indent size in pixels of tree data | number | 15 |
5151
| loading | Loading status of table | boolean\|[object](/components/spin) | `false` |
5252
| locale | i18n text including filter, sort, empty text, etc | object | filterConfirm: 'Ok' <br> filterReset: 'Reset' <br> emptyText: 'No Data' |
53-
| pagination | Pagination [config](#pagination) or [`Pagination`] (/components/pagination/), hide it by setting it to `false` | object | |
53+
| pagination | Config of pagination. You can ref table pagination [config](#pagination) or full [`pagination`](/components/pagination/) document, hide it by setting it to `false` | object | |
5454
| rowClassName | Row's className | Function(record, index):string | - |
5555
| rowKey | Row's unique key, could be a string or function that returns a string | string\|Function(record):string | `key` |
5656
| rowSelection | Row selection [config](#rowSelection) | object | null |
@@ -81,9 +81,11 @@ Follow [Vue jsx](https://github.com/vuejs/babel-plugin-transform-vue-jsx) syntax
8181
xxx...
8282
},
8383
on: {
84-
click: () => {}, // click row
85-
mouseenter: () => {}, // mouse enter row
86-
xxxx...
84+
click: (event) => {}, // click row
85+
doubleclick: (event) => {}, // double click row
86+
contextmenu: (event) => {} // right button click row
87+
mouseenter: (event) => {} // mouse enter row
88+
mouseleave: (event) => {} // mouse leave row
8789
},
8890
};
8991
)}

0 commit comments

Comments
 (0)