-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(comp:table): add virtualHorizontal support (#1776)
- Loading branch information
Showing
32 changed files
with
1,034 additions
and
325 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
title: | ||
zh: 自动高度 + 虚拟滚动 | ||
en: Auto height + Virtual | ||
order: 91 | ||
order: 93 | ||
hidden: true | ||
--- |
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,6 @@ | ||
--- | ||
title: | ||
zh: 横向&竖向虚拟滚动 | ||
en: Virtual horizontal and vertical | ||
order: 92 | ||
--- |
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,57 @@ | ||
<template> | ||
<IxTable | ||
:columns="columns" | ||
:dataSource="data" | ||
:pagination="false" | ||
virtual | ||
virtualHorizontal | ||
:scroll="scroll" | ||
:virtualColWidth="150" | ||
> | ||
</IxTable> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { h } from 'vue' | ||
import { TableColumn } from '@idux/components/table' | ||
import { IxText } from '@idux/components/text' | ||
interface Data { | ||
key: number | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
[name: string]: any | ||
} | ||
const columns: TableColumn<Data>[] = [] | ||
const columnCount = 1000 | ||
const rowCount = 1000 | ||
const customCell = ({ value }: { value: string }) => { | ||
return h(IxText, { ellipsis: true, tooltip: 'native' }, () => value) | ||
} | ||
for (let index = 0; index < columnCount; index++) { | ||
const key = `column${index}` | ||
columns.push({ | ||
title: key, | ||
dataKey: key, | ||
width: index % 2 === 1 ? 150 : 170, | ||
fixed: index === 0 ? 'start' : index === columnCount - 1 ? 'end' : undefined, | ||
customCell, | ||
}) | ||
} | ||
const data: Data[] = [] | ||
for (let index = 0; index < rowCount; index++) { | ||
const item: Data = { key: index } | ||
for (let colIndex = 0; colIndex < columnCount; colIndex++) { | ||
item[`column${colIndex}`] = `row-${index} col-${colIndex} hahahahahahahahahahah` | ||
} | ||
data.push(item) | ||
} | ||
const scroll = { height: 800 } | ||
</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: Virtual horizontal | ||
order: 91 | ||
--- | ||
|
||
## zh | ||
|
||
通过 `virtualHorizontal` 开启横向虚拟滚动,横向虚拟滚动必须指定列宽 | ||
|
||
## en | ||
|
||
Enable horizontal virtual scroll via `virtualHorizontal`, column width must be provided. |
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,38 @@ | ||
<template> | ||
<IxTable :columns="columns" :dataSource="data" :pagination="false" virtualHorizontal :virtualColWidth="150"> | ||
</IxTable> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { TableColumn } from '@idux/components/table' | ||
interface Data { | ||
key: number | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
[name: string]: any | ||
} | ||
const columns: TableColumn<Data>[] = [] | ||
const columnCount = 100 | ||
for (let index = 0; index < columnCount; index++) { | ||
const key = `column${index}` | ||
columns.push({ | ||
title: key, | ||
dataKey: key, | ||
width: index % 2 === 1 ? 150 : 170, | ||
}) | ||
} | ||
const data: Data[] = [] | ||
for (let index = 0; index < 8; index++) { | ||
const item: Data = { key: index } | ||
for (let colIndex = 0; colIndex < columnCount; colIndex++) { | ||
item[`column${colIndex}`] = `row-${index} col-${colIndex}` | ||
} | ||
data.push(item) | ||
} | ||
</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
Oops, something went wrong.