-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(table): modify table functions and style (#672)
* add tree table indent support * fix tree table sort function * fix sort orderby(was't controlled previously) * add filter function for table * expandable column now extends base column(usual data column) * modify table style according to new design
- Loading branch information
Showing
48 changed files
with
1,188 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
@height-md: 32px; | ||
@height-lg: 40px; | ||
@height-xl: 48px; | ||
@height-xxl: 64px; | ||
|
||
@line-height-base: 1.5715; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
title: | ||
zh: 行/列合并 | ||
en: Merge row and column | ||
order: 60 | ||
order: 10 | ||
--- | ||
|
||
## zh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: | ||
zh: 可筛选 | ||
en: Filterable | ||
order: 52 | ||
--- | ||
|
||
## zh | ||
|
||
通过设置 `filterable` 对某一列数据进行筛选。 | ||
|
||
## en | ||
|
||
Sort a column of data by setting `filterable`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<template> | ||
<IxTable :columns="columns" :dataSource="data" :pagination="false"> | ||
<template #name="{ value }"> | ||
<a>{{ value }}</a> | ||
</template> | ||
</IxTable> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { TableColumn } from '@idux/components/table' | ||
interface Data { | ||
key: number | ||
name: string | ||
age: number | ||
grade: number | ||
address: string | ||
} | ||
type AgeFilter = (age: number) => boolean | ||
const columns: TableColumn<Data>[] = [ | ||
{ | ||
title: 'Name', | ||
dataKey: 'name', | ||
customRender: 'name', | ||
}, | ||
{ | ||
title: 'Age', | ||
dataKey: 'age', | ||
sortable: { | ||
sorter: (curr, next) => curr.age - next.age, | ||
}, | ||
filterable: { | ||
filters: [ | ||
{ | ||
text: 'over 19', | ||
value: (age: number) => age > 19, | ||
}, | ||
{ | ||
text: 'below 21', | ||
value: (age: number) => age < 21, | ||
}, | ||
], | ||
filter(currentFilterBy, record) { | ||
return currentFilterBy.every(filterBy => filterBy(record.age)) | ||
}, | ||
}, | ||
} as TableColumn<Data, AgeFilter>, | ||
{ | ||
title: 'Grade', | ||
dataKey: 'grade', | ||
}, | ||
{ | ||
title: 'Address', | ||
dataKey: 'address', | ||
filterable: { | ||
filters: [ | ||
{ | ||
text: 'Sidney', | ||
value: 'Sidney', | ||
}, | ||
{ | ||
text: 'New York', | ||
value: 'New York', | ||
}, | ||
], | ||
handleFilter(currentFilterBy, record) { | ||
return currentFilterBy.every(filterBy => record.address.includes(filterBy)) | ||
}, | ||
}, | ||
} as TableColumn<Data, string>, | ||
] | ||
const data: Data[] = [ | ||
{ | ||
key: 1, | ||
name: 'John Brown', | ||
age: 18, | ||
grade: 1, | ||
address: 'New York No. 1 Lake Park', | ||
}, | ||
{ | ||
key: 2, | ||
name: 'Jim Green', | ||
age: 20, | ||
grade: 3, | ||
address: 'London No. 1 Lake Park', | ||
}, | ||
{ | ||
key: 3, | ||
name: 'Joe Black', | ||
age: 19, | ||
grade: 2, | ||
address: 'Sidney No. 1 Lake Park', | ||
}, | ||
{ | ||
key: 4, | ||
name: 'Disabled User', | ||
age: 21, | ||
grade: 2, | ||
address: 'Sidney No. 1 Lake Park', | ||
}, | ||
] | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: | ||
zh: 受控的筛选 | ||
en: Controlled filterable | ||
order: 53 | ||
--- | ||
|
||
## zh | ||
|
||
如果设置了 `filterable` 的 `filterby`,表格列的筛选将为受控状态。 | ||
|
||
## en | ||
|
||
If `filterby` of `filterable` is set, the filtering of the column will be in a controlled state. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<template> | ||
<IxSpace> | ||
<IxButton @Click="filterByAge19">Filter By Age(over 19)</IxButton> | ||
<IxButton @Click="filterBySidney">Filter By Address(sidney)</IxButton> | ||
<IxButton @Click="clear">Clear</IxButton> | ||
</IxSpace> | ||
<IxTable :columns="columns" :dataSource="data" :pagination="false"> | ||
<template #name="{ value }"> | ||
<a>{{ value }}</a> | ||
</template> | ||
</IxTable> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { reactive } from 'vue' | ||
import { TableColumn, TableColumnFilterable } from '@idux/components/table' | ||
interface Data { | ||
key: number | ||
name: string | ||
age: number | ||
grade: number | ||
address: string | ||
} | ||
type AgeFilter = (age: number) => boolean | ||
const ageFilterable: TableColumnFilterable<Data, AgeFilter> = reactive({ | ||
filters: [ | ||
{ | ||
text: 'over 19', | ||
value: (age: number) => age > 19, | ||
}, | ||
{ | ||
text: 'below 21', | ||
value: (age: number) => age < 21, | ||
}, | ||
], | ||
filter(currentFilterBy, record) { | ||
return currentFilterBy.every(filterBy => filterBy(record.age)) | ||
}, | ||
filterBy: [], | ||
onChange(currentFilterBy) { | ||
ageFilterable.filterBy = currentFilterBy | ||
}, | ||
}) | ||
const addressFilterable: TableColumnFilterable<Data, string> = reactive({ | ||
filters: [ | ||
{ | ||
text: 'Sidney', | ||
value: 'Sidney', | ||
}, | ||
{ | ||
text: 'New York', | ||
value: 'New York', | ||
}, | ||
], | ||
filter(currentFilterBy, record) { | ||
return currentFilterBy.every(filterBy => record.address.includes(filterBy)) | ||
}, | ||
filterBy: [], | ||
onChange(currentFilterBy) { | ||
addressFilterable.filterBy = currentFilterBy | ||
}, | ||
}) | ||
const filterByAge19 = () => { | ||
ageFilterable.filterBy = [ageFilterable.filters[0].value] | ||
addressFilterable.filterBy = [] | ||
} | ||
const filterBySidney = () => { | ||
ageFilterable.filterBy = [] | ||
addressFilterable.filterBy = ['Sidney'] | ||
} | ||
const clear = () => { | ||
ageFilterable.filterBy = [] | ||
addressFilterable.filterBy = [] | ||
} | ||
const columns: TableColumn<Data>[] = [ | ||
{ | ||
title: 'Name', | ||
dataKey: 'name', | ||
customRender: 'name', | ||
}, | ||
{ | ||
title: 'Age', | ||
dataKey: 'age', | ||
sortable: { | ||
sorter: (curr, next) => curr.age - next.age, | ||
}, | ||
filterable: ageFilterable, | ||
} as TableColumn<Data, AgeFilter>, | ||
{ | ||
title: 'Grade', | ||
dataKey: 'grade', | ||
}, | ||
{ | ||
title: 'Address', | ||
dataKey: 'address', | ||
filterable: addressFilterable, | ||
} as TableColumn<Data, string>, | ||
] | ||
const data: Data[] = [ | ||
{ | ||
key: 1, | ||
name: 'John Brown', | ||
age: 18, | ||
grade: 1, | ||
address: 'New York No. 1 Lake Park', | ||
}, | ||
{ | ||
key: 2, | ||
name: 'Jim Green', | ||
age: 20, | ||
grade: 3, | ||
address: 'London No. 1 Lake Park', | ||
}, | ||
{ | ||
key: 3, | ||
name: 'Joe Black', | ||
age: 19, | ||
grade: 2, | ||
address: 'Sidney No. 1 Lake Park', | ||
}, | ||
{ | ||
key: 4, | ||
name: 'Disabled User', | ||
age: 21, | ||
grade: 2, | ||
address: 'Sidney No. 1 Lake Park', | ||
}, | ||
] | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: | ||
zh: 树表格 | ||
en: Tree table | ||
order: 80 | ||
--- | ||
|
||
## zh | ||
|
||
树形表格 | ||
|
||
## en | ||
|
||
Tree table |
Oops, something went wrong.