Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(comp:table): incorrect serial number (#1370)
- Loading branch information
Showing
18 changed files
with
217 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: | ||
zh: 带序号的表格 | ||
en: Table with index | ||
order: 48 | ||
--- | ||
|
||
## zh | ||
|
||
配置 `type: 'indexable'` 即可使用序号列。 | ||
|
||
## en | ||
|
||
You can configure `type: 'indexable'` to use an index column. |
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,73 @@ | ||
<template> | ||
<IxTable :columns="columns" :dataSource="data"> | ||
<template #name="{ value }"> | ||
<IxButton mode="link">{{ value }}</IxButton> | ||
</template> | ||
<template #action="{ record }"> | ||
<IxButtonGroup :gap="8" mode="link" separator="|"> | ||
<IxButton>Invite {{ record.name }}</IxButton> | ||
<IxButton>Delete</IxButton> | ||
</IxButtonGroup> | ||
</template> | ||
</IxTable> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { h } from 'vue' | ||
import { TableColumn } from '@idux/components/table' | ||
import { IxTag } from '@idux/components/tag' | ||
interface Data { | ||
key: number | ||
name: string | ||
age: number | ||
address: string | ||
tags: string[] | ||
} | ||
const columns: TableColumn<Data>[] = [ | ||
{ type: 'indexable' }, | ||
{ | ||
title: 'Name', | ||
dataKey: 'name', | ||
customCell: 'name', | ||
}, | ||
{ | ||
title: 'Age', | ||
dataKey: 'age', | ||
}, | ||
{ | ||
title: 'Address', | ||
dataKey: 'address', | ||
}, | ||
{ | ||
title: 'Tags', | ||
dataKey: 'tags', | ||
customCell: ({ value }) => | ||
value.map((tag: string) => { | ||
let color = tag.length > 5 ? 'warning' : 'success' | ||
if (tag === 'loser') { | ||
color = 'error' | ||
} | ||
return h(IxTag, { color }, { default: () => tag.toUpperCase() }) | ||
}), | ||
}, | ||
{ | ||
title: 'Action', | ||
key: 'action', | ||
customCell: 'action', | ||
}, | ||
] | ||
const data: Data[] = [] | ||
for (let index = 0; index < 100; index++) { | ||
data.push({ | ||
key: index, | ||
name: `Edrward ${index}`, | ||
age: 18 + index, | ||
address: `London Park no. ${index}`, | ||
tags: ['nice', 'developer'], | ||
}) | ||
} | ||
</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
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
Oops, something went wrong.