Skip to content

Commit a7a16ad

Browse files
committed
Merge branch 'virtual-scroll'
2 parents 4d6f849 + 0e44594 commit a7a16ad

31 files changed

+741
-363
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
rules: {
99
"no-console": "off",
1010
"no-debugger": "off",
11-
"no-unused-vars": "off",
11+
"no-unused-vars": "warn",
1212
"no-useless-escape": "off",
1313
// plugin:vue/recommended 规则
1414
"vue/attributes-order": "error",

CHANGE-LOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
vx.x.x(TPL)
2+
3+
- Breaking Changes
4+
- Feature
5+
- Bug Fixes
6+
- Performance Improvements
7+
- Style
8+
- Dependencies Changes
9+
10+
V2.7.0
11+
12+
Breaking Changes
13+
14+
- 调整了虚拟滚动功能默认最小行高度。由 “42px” 改为了 “40px”,你可以通过`minRowHeight`属性控制
15+
16+
Feature
17+
18+
- 添加 scrollToRowKey 实例方法
19+
20+
Bug Fixes
21+
22+
- 修复虚拟滚动功能最小高度 `minRowHeight`值与表格行高一样,滚动条高度没撑开的问题
23+
- 修复虚拟滚动功能,浏览器窗口大小改变表格白屏的问题
24+
- 修复长时间键盘操作(keycode 38 = Up)导致选中框消失的的问题
25+
26+
Performance Improvements
27+
28+
- 优化虚拟滚动功能渲染速度。使用非响应式变量替代
29+
- 优化虚拟滚动功能缓冲策略。将缓冲倍数改为缓冲行数

examples/src/demo/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ export default {
482482
} else {
483483
this.resetTableData();
484484
}
485+
486+
// scroll to top
487+
this.$refs["tableRef"].scrollTo({ top: 0 });
485488
},
486489
487490
// switch theme

examples/src/docs/en/ve-table/api/db.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,15 @@ export const db = {
462462
instanceMethods: {
463463
data: [
464464
{
465-
name: "scrollTop",
465+
name: "scrollTo",
466466
desc: `Scrolls the table to the specified position`,
467467
param: "Refer to <a href='https://developer.mozilla.org/zh-CN/docs/Web/API/Element/scrollTo'> MDN scrollTo</a>",
468468
},
469+
{
470+
name: "scrollToRowKey",
471+
desc: `Scroll the table to the location of the row key`,
472+
param: "{rowKey}",
473+
},
469474
],
470475
columns: columnsType2,
471476
},
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
<template>
22
<div>
3-
<h2>实例方法</h2>
3+
<h2>Instance Methods</h2>
44
<Explain />
55
<ScrollTo />
6+
<ScrollToRowKey />
7+
<API title="API" anchor="API" desc="Instance Methods" />
68
</div>
79
</template>
810
<script>
911
import Explain from "./explain.md";
1012
import ScrollTo from "./scroll-to.md";
13+
import ScrollToRowKey from "./scroll-to-row-key.md";
14+
import API from "../api/instance-methods";
1115
1216
export default {
1317
name: "basic-main",
1418
components: {
1519
Explain,
1620
ScrollTo,
21+
ScrollToRowKey,
22+
API,
1723
},
1824
};
1925
</script>
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
:::anchor scrollToRowKey
2+
3+
:::demo 1、Scroll the table to the location of the row key
4+
5+
```html
6+
<template>
7+
<div>
8+
<div style="margin-bottom:20px;line-height:3.0;">
9+
<button class="button-demo" @click="scrollToRowKey(30)">滚动到rowKey为30的行</button>
10+
<button class="button-demo" @click="scrollToRowKey(50)">滚动到rowKey为50的行</button>
11+
<button class="button-demo" @click="scrollToRowKey(0)">滚动到rowKey为0的行</button>
12+
</div>
13+
<ve-table
14+
ref="tableRef"
15+
style="width:1000px"
16+
:scroll-width="1600"
17+
:max-height="350"
18+
border-y
19+
:columns="columns"
20+
:table-data="tableData"
21+
rowKeyFieldName="rowkey"
22+
/>
23+
</div>
24+
</template>
25+
26+
<script>
27+
export default {
28+
data() {
29+
return {
30+
columns: [
31+
{
32+
field: "col1",
33+
key: "a",
34+
title: "col1",
35+
width: 50,
36+
fixed: "left",
37+
},
38+
{
39+
title: "col2-col3",
40+
fixed: "left",
41+
children: [
42+
{
43+
field: "col2",
44+
key: "b",
45+
title: "col2",
46+
width: 50,
47+
},
48+
{
49+
field: "col3",
50+
key: "c",
51+
title: "col3",
52+
width: 50,
53+
},
54+
],
55+
},
56+
{
57+
title: "col4-col5-col6",
58+
children: [
59+
{
60+
title: "col4-col5",
61+
children: [
62+
{
63+
field: "col4",
64+
key: "d",
65+
title: "col4",
66+
width: 130,
67+
},
68+
{
69+
field: "col5",
70+
key: "e",
71+
title: "col5",
72+
width: 140,
73+
},
74+
],
75+
},
76+
{
77+
title: "col6",
78+
field: "col6",
79+
key: "f",
80+
width: 140,
81+
},
82+
],
83+
},
84+
{
85+
title: "col7",
86+
fixed: "right",
87+
children: [
88+
{
89+
title: "col7-1",
90+
field: "col7",
91+
key: "g",
92+
width: 50,
93+
},
94+
],
95+
},
96+
{
97+
field: "col8",
98+
key: "h",
99+
title: "col8",
100+
width: 50,
101+
fixed: "right",
102+
},
103+
],
104+
};
105+
},
106+
methods: {
107+
initTableData() {
108+
let data = [];
109+
for (let i = 0; i < 80; i++) {
110+
data.push({
111+
rowkey: i,
112+
col1: i,
113+
col2: i,
114+
col3: i,
115+
col4: i,
116+
col5: i,
117+
col6: i,
118+
col7: i,
119+
col8: i,
120+
});
121+
}
122+
this.tableData = data;
123+
},
124+
// scroll y
125+
scrollToRowKey(rowKey) {
126+
this.$refs["tableRef"].scrollToRowKey({ rowKey: rowKey });
127+
},
128+
},
129+
created() {
130+
this.initTableData();
131+
},
132+
};
133+
</script>
134+
```
135+
136+
:::

examples/src/docs/en/ve-table/instance-methods/scroll-to.md

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

3-
:::demo 1、Params refer to [scrollTo](https://developer.mozilla.org/zh-CN/docs/Web/API/Element/scrollTo)
3+
:::demo 1、Scroll the table to the specified location(px)<br>2、Params refer to [scrollTo](https://developer.mozilla.org/zh-CN/docs/Web/API/Element/scrollTo)
44

55
```html
66
<template>

examples/src/docs/zh/ve-table/api/db.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,15 @@ export const db = {
462462
instanceMethods: {
463463
data: [
464464
{
465-
name: "scrollTop",
465+
name: "scrollTo",
466466
desc: `使表格滚动到指定的位置`,
467467
param: "参考<a href='https://developer.mozilla.org/zh-CN/docs/Web/API/Element/scrollTo'> MDN scrollTo</a>",
468468
},
469+
{
470+
name: "scrollToRowKey",
471+
desc: `将表格滚动到行为rowKey的位置`,
472+
param: "{rowKey}",
473+
},
469474
],
470475
columns: columnsType2,
471476
},

examples/src/docs/zh/ve-table/instance-methods/main.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33
<h2>实例方法</h2>
44
<Explain />
55
<ScrollTo />
6+
<ScrollToRowKey />
7+
<API title="API" anchor="API" desc="实例方法" />
68
</div>
79
</template>
810
<script>
911
import Explain from "./explain.md";
1012
import ScrollTo from "./scroll-to.md";
13+
import ScrollToRowKey from "./scroll-to-row-key.md";
14+
import API from "../api/instance-methods";
1115
1216
export default {
1317
name: "basic-main",
1418
components: {
1519
Explain,
1620
ScrollTo,
21+
ScrollToRowKey,
22+
API,
1723
},
1824
};
1925
</script>

0 commit comments

Comments
 (0)