Skip to content

Commit 7fd5495

Browse files
committed
完善虚拟滚动展开表格示例
1 parent ea01fa6 commit 7fd5495

File tree

6 files changed

+341
-82
lines changed

6 files changed

+341
-82
lines changed

examples/src/docs/en/ve-table/virtual-scroll/main.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<RowCheckbox />
99
<RowRadio />
1010
<RowExpand />
11+
<RowExpandTable />
1112
<ColumnFixed />
1213
<FooterSummary />
1314
<API
@@ -24,6 +25,7 @@ import AutoHeight from "./auto-height.md";
2425
import RowCheckbox from "./row-checkbox.md";
2526
import RowRadio from "./row-radio.md";
2627
import RowExpand from "./row-expand.md";
28+
import RowExpandTable from "./row-expand-table.md";
2729
import FooterSummary from "../footer-summary/virtual-scroll.md";
2830
import ColumnFixed from "./column-fixed.md";
2931
import RowIndex from "./row-index.md";
@@ -38,6 +40,7 @@ export default {
3840
RowCheckbox,
3941
RowRadio,
4042
RowExpand,
43+
RowExpandTable,
4144
ColumnFixed,
4245
FooterSummary,
4346
RowIndex,
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
:::anchor Combination Row Expand Table
2+
3+
:::demo
4+
5+
```html
6+
<template>
7+
<div>
8+
<ve-table
9+
fixed-header
10+
:max-height="500"
11+
:virtual-scroll-option="virtualScrollOption"
12+
:expand-option="expandOption"
13+
:columns="columns"
14+
:table-data="tableData"
15+
row-key-field-name="rowKey"
16+
/>
17+
</div>
18+
</template>
19+
20+
<script>
21+
// 此示例是在组件内部定义了一个子组件。你当然也可以通过 `import`关键字导入一个组件
22+
const ChildTableComp = {
23+
name: "ChildTableComp",
24+
template: `
25+
<div class="child-table-comp">
26+
<span style="font-weight:bold;">Table Name:{{row.name}}</span>
27+
<ve-table
28+
:max-height="300"
29+
:fixed-header="true"
30+
style="width:100%"
31+
:columns="columns"
32+
:table-data="tableData"
33+
:virtual-scroll-option="{
34+
enable: false,
35+
}"
36+
/>
37+
</div>
38+
`,
39+
props: {
40+
row: Object,
41+
},
42+
data() {
43+
return {
44+
columns: [
45+
{ field: "col1", key: "a", title: "Col1" },
46+
{ field: "col2", key: "b", title: "Col2" },
47+
{ field: "col3", key: "c", title: "Col3" },
48+
{ field: "col4", key: "d", title: "Col4" },
49+
{ field: "col5", key: "e", title: "Col5" },
50+
],
51+
tableData: [
52+
{
53+
col1: "1",
54+
col2: "2",
55+
col3: "3",
56+
col4: "4",
57+
col5: "5",
58+
},
59+
{
60+
col1: "1",
61+
col2: "2",
62+
col3: "3",
63+
col4: "4",
64+
col5: "5",
65+
},
66+
{
67+
col1: "1",
68+
col2: "2",
69+
col3: "3",
70+
col4: "4",
71+
col5: "5",
72+
},
73+
{
74+
col1: "1",
75+
col2: "2",
76+
col3: "3",
77+
col4: "4",
78+
col5: "5",
79+
},
80+
],
81+
};
82+
},
83+
};
84+
85+
export default {
86+
data() {
87+
return {
88+
virtualScrollOption: {
89+
// 是否开启
90+
enable: true,
91+
},
92+
expandOption: {
93+
defaultExpandedRowKeys: [2],
94+
render: ({ row, column, rowIndex }, h) => {
95+
return <ChildTableComp row={row} />;
96+
},
97+
},
98+
99+
columns: [
100+
{
101+
field: "",
102+
key: "a",
103+
// type=expand
104+
type: "expand",
105+
title: "",
106+
width: 50,
107+
align: "center",
108+
},
109+
{
110+
field: "name",
111+
key: "b",
112+
title: "Name",
113+
width: 200,
114+
align: "left",
115+
renderBodyCell: ({ row }, h) => {
116+
return <span domPropsInnerHTML={row.name}></span>;
117+
},
118+
},
119+
{
120+
field: "hobby",
121+
key: "c",
122+
title: "Hobby",
123+
width: 300,
124+
align: "left",
125+
},
126+
{
127+
field: "address",
128+
key: "d",
129+
title: "Address",
130+
width: "",
131+
align: "left",
132+
},
133+
],
134+
tableData: [],
135+
};
136+
},
137+
methods: {
138+
initData() {
139+
let data = [];
140+
for (let i = 0; i < 10000; i++) {
141+
data.push({
142+
rowKey: i,
143+
name: `name${i}`,
144+
hobby: `hobby${i}`,
145+
address: `address${i}`,
146+
});
147+
}
148+
149+
this.tableData = data;
150+
},
151+
},
152+
created() {
153+
this.initData();
154+
},
155+
};
156+
</script>
157+
```
158+
159+
:::

examples/src/docs/en/ve-table/virtual-scroll/row-expand.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
:::anchor Combination Row Expand
22

3-
:::demo Row expand, Need specify `rowKeyFieldName` property
3+
:::demo
44

55
```html
66
<template>

examples/src/docs/zh/ve-table/virtual-scroll/main.vue

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
<div>
33
<h2>虚拟滚动</h2>
44
<Explain />
5-
<!-- <Base />
5+
<Base />
66
<AutoHeight />
77
<RowIndex />
88
<RowCheckbox />
9-
<RowRadio /> -->
9+
<RowRadio />
1010
<RowExpand />
11-
<!-- <ColumnFixed />
12-
<FooterSummary /> -->
11+
<RowExpandTable />
12+
<ColumnFixed />
13+
<FooterSummary />
1314
<API title="API" anchor="API" desc="virtualScrollOption 虚拟滚动配置" />
1415
</div>
1516
</template>
@@ -20,6 +21,7 @@ import AutoHeight from "./auto-height.md";
2021
import RowCheckbox from "./row-checkbox.md";
2122
import RowRadio from "./row-radio.md";
2223
import RowExpand from "./row-expand.md";
24+
import RowExpandTable from "./row-expand-table.md";
2325
import FooterSummary from "../footer-summary/virtual-scroll.md";
2426
import ColumnFixed from "./column-fixed.md";
2527
import RowIndex from "./row-index.md";
@@ -29,14 +31,15 @@ export default {
2931
name: "basic-main",
3032
components: {
3133
Explain,
32-
// Base,
33-
// AutoHeight,
34-
// RowCheckbox,
35-
// RowRadio,
34+
Base,
35+
AutoHeight,
36+
RowCheckbox,
37+
RowRadio,
3638
RowExpand,
37-
// ColumnFixed,
38-
// FooterSummary,
39-
// RowIndex,
39+
RowExpandTable,
40+
ColumnFixed,
41+
FooterSummary,
42+
RowIndex,
4043
API,
4144
},
4245
};

0 commit comments

Comments
 (0)