-
Notifications
You must be signed in to change notification settings - Fork 141
/
VirtualHorizontal.vue
52 lines (41 loc) · 1.09 KB
/
VirtualHorizontal.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<template>
<IxTable :columns="columns" :dataSource="data" :pagination="false" virtualHorizontal :virtualColWidth="150">
</IxTable>
<br />
<IxButton @click="toggleEmpty"> ToggleEmpty </IxButton>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
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 fullData: 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}`
}
fullData.push(item)
}
const data = ref<Data[]>(fullData)
const toggleEmpty = () => {
if (data.value.length > 0) {
data.value = []
} else {
data.value = fullData
}
}
</script>