Virtualized Table 虚拟化表格 beta

在前端开发领域,表格一直都是一个高频出现的组件,尤其是在中后台和数据分析场景。 但是,对于 Table V1来说,当一屏里超过 1000 条数据记录时,就会出现卡顿等性能问题,体验不是很好。

通过虚拟化表格组件,超大数据渲染将不再是一个头疼的问题。

TIP

该组件仍在测试中,生产环境使用可能有风险。 若您发现了 bug 或问题,请于 GitHub 报告给我们以便修复。 同时,有一些 API 并未在此文档中提及,因为部分还没有开发完全,因此我们不在此提及。

即使虚拟化的表格是高效的,但是当数据负载过大时,网络内存容量也会成为您应用程序的瓶颈。 因此请牢记,虚拟化表格永远不是最完美的解决方案,请考虑数据分页、过滤器等优化方案。

基础用法

让我们演示虚拟化表的性能,用10列和1 000行渲染一个基本示例。

Row 0 - Col 0
Row 0 - Col 1
Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9
Row 1 - Col 0
Row 1 - Col 1
Row 1 - Col 2
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 2 - Col 0
Row 2 - Col 1
Row 2 - Col 2
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9
Row 3 - Col 0
Row 3 - Col 1
Row 3 - Col 2
Row 3 - Col 3
Row 3 - Col 4
Row 3 - Col 5
Row 3 - Col 6
Row 3 - Col 7
Row 3 - Col 8
Row 3 - Col 9
Row 4 - Col 0
Row 4 - Col 1
Row 4 - Col 2
Row 4 - Col 3
Row 4 - Col 4
Row 4 - Col 5
Row 4 - Col 6
Row 4 - Col 7
Row 4 - Col 8
Row 4 - Col 9
Row 5 - Col 0
Row 5 - Col 1
Row 5 - Col 2
Row 5 - Col 3
Row 5 - Col 4
Row 5 - Col 5
Row 5 - Col 6
Row 5 - Col 7
Row 5 - Col 8
Row 5 - Col 9
Row 6 - Col 0
Row 6 - Col 1
Row 6 - Col 2
Row 6 - Col 3
Row 6 - Col 4
Row 6 - Col 5
Row 6 - Col 6
Row 6 - Col 7
Row 6 - Col 8
Row 6 - Col 9
Row 7 - Col 0
Row 7 - Col 1
Row 7 - Col 2
Row 7 - Col 3
Row 7 - Col 4
Row 7 - Col 5
Row 7 - Col 6
Row 7 - Col 7
Row 7 - Col 8
Row 7 - Col 9
Row 8 - Col 0
Row 8 - Col 1
Row 8 - Col 2
Row 8 - Col 3
Row 8 - Col 4
Row 8 - Col 5
Row 8 - Col 6
Row 8 - Col 7
Row 8 - Col 8
Row 8 - Col 9
Column 0
Column 1
Column 2
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8
Column 9

自动调整大小

如果不想手动向表格传递 widthheight 属性,可以使用 AutoResizer 对表格组件进行封装。 这会自动为你更新宽度和高度。

尝试调整您的浏览器大小来看看它是如何工作的。

TIP

由于 AutoResizer 组件的默认高度是 100%,所以请确保该组件的父元素拥有固定的高度值。 或者,您可以通过将 style 属性传递到 AutoResizer 来定义它。

Row 0 - Col 0
Row 0 - Col 1
Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9
Row 1 - Col 0
Row 1 - Col 1
Row 1 - Col 2
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 2 - Col 0
Row 2 - Col 1
Row 2 - Col 2
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9

自定义单元格渲染器

当然,您可以根据您的需要呈现表格单元格。 这是如何自定义您的单元格的简单例子。

Tom
Tom
Tom
Tom
Tom
Tom
Tom
Tom
Tom
Name
Operations
2020/10/01
2020/10/01
2020/10/01
2020/10/01
2020/10/01
2020/10/01
2020/10/01
2020/10/01
2020/10/01
Date

带有选择的表格

使用自定义的单元格渲染来给表格组件添加选择的能力。

Row 0 - Col 1
Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9
Row 0 - Col 10
Row 1 - Col 1
Row 1 - Col 2
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 1 - Col 10
Row 2 - Col 1
Row 2 - Col 2
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9
Row 2 - Col 10

可编辑单元格

类似上面添加筛选框的方法,我们可以用同样的方法实现可编辑单元格。

Row 0 - Col 0
Row 0 - Col 1
Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9
Row 1 - Col 0
Row 1 - Col 1
Row 1 - Col 2
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 2 - Col 0
Row 2 - Col 1
Row 2 - Col 2
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9

带状态的表格

可将表格内容 highlight 显示,方便区分「成功、信息、警告、危险」等内容。

要自定义行的外观,请使用 row-class-name 属性。 举个例子,每10行会自动添加 bg-blue-200 类名,每5行会添加 bg-red-100 类名。

Tom
Tom
Tom
Tom
Tom
Tom
Tom
Tom
Tom
Name
Operations
2020/10/01
2020/10/01
2020/10/01
2020/10/01
2020/10/01
2020/10/01
2020/10/01
2020/10/01
2020/10/01
Date

表格行的粘性布局

您可以简单地使用 fixed-data 属性来实现将某些行固定到表格的头部。

您可以根据滚动事件动态设置粘性行,如这个示例所示。

Row 1 - Col 0
Row 1 - Col 1
Row 1 - Col 2
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 2 - Col 0
Row 2 - Col 1
Row 2 - Col 2
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9
Row 3 - Col 0
Row 3 - Col 1
Row 3 - Col 2
Row 3 - Col 3
Row 3 - Col 4
Row 3 - Col 5
Row 3 - Col 6
Row 3 - Col 7
Row 3 - Col 8
Row 3 - Col 9
Row 4 - Col 0
Row 4 - Col 1
Row 4 - Col 2
Row 4 - Col 3
Row 4 - Col 4
Row 4 - Col 5
Row 4 - Col 6
Row 4 - Col 7
Row 4 - Col 8
Row 4 - Col 9
Row 5 - Col 0
Row 5 - Col 1
Row 5 - Col 2
Row 5 - Col 3
Row 5 - Col 4
Row 5 - Col 5
Row 5 - Col 6
Row 5 - Col 7
Row 5 - Col 8
Row 5 - Col 9
Row 6 - Col 0
Row 6 - Col 1
Row 6 - Col 2
Row 6 - Col 3
Row 6 - Col 4
Row 6 - Col 5
Row 6 - Col 6
Row 6 - Col 7
Row 6 - Col 8
Row 6 - Col 9
Row 7 - Col 0
Row 7 - Col 1
Row 7 - Col 2
Row 7 - Col 3
Row 7 - Col 4
Row 7 - Col 5
Row 7 - Col 6
Row 7 - Col 7
Row 7 - Col 8
Row 7 - Col 9
Row 8 - Col 0
Row 8 - Col 1
Row 8 - Col 2
Row 8 - Col 3
Row 8 - Col 4
Row 8 - Col 5
Row 8 - Col 6
Row 8 - Col 7
Row 8 - Col 8
Row 8 - Col 9
Column 0
Column 1
Column 2
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8
Column 9
Row 0 - Col 0
Row 0 - Col 1
Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9

固定列表格

如果您想要有列粘贴左侧或右侧的某种原因。 您可以通过向表中添加特殊属性来实现这一点。

您可以设置该行的 fixed 属性为 true (代表FixedDir.LEFT)、FixedDir.LEFTFixedDir.RIGHT

Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 1 - Col 2
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 2 - Col 2
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 3 - Col 2
Row 3 - Col 3
Row 3 - Col 4
Row 3 - Col 5
Row 3 - Col 6
Row 3 - Col 7
Row 3 - Col 8
Row 4 - Col 2
Row 4 - Col 3
Row 4 - Col 4
Row 4 - Col 5
Row 4 - Col 6
Row 4 - Col 7
Row 4 - Col 8
Row 5 - Col 2
Row 5 - Col 3
Row 5 - Col 4
Row 5 - Col 5
Row 5 - Col 6
Row 5 - Col 7
Row 5 - Col 8
Row 6 - Col 2
Row 6 - Col 3
Row 6 - Col 4
Row 6 - Col 5
Row 6 - Col 6
Row 6 - Col 7
Row 6 - Col 8
Row 7 - Col 2
Row 7 - Col 3
Row 7 - Col 4
Row 7 - Col 5
Row 7 - Col 6
Row 7 - Col 7
Row 7 - Col 8
Row 8 - Col 2
Row 8 - Col 3
Row 8 - Col 4
Row 8 - Col 5
Row 8 - Col 6
Row 8 - Col 7
Row 8 - Col 8
Column 2
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8
Row 0 - Col 0
Row 0 - Col 1
Row 1 - Col 0
Row 1 - Col 1
Row 2 - Col 0
Row 2 - Col 1
Row 3 - Col 0
Row 3 - Col 1
Row 4 - Col 0
Row 4 - Col 1
Row 5 - Col 0
Row 5 - Col 1
Row 6 - Col 0
Row 6 - Col 1
Row 7 - Col 0
Row 7 - Col 1
Row 8 - Col 0
Row 8 - Col 1
Column 0
Column 1
Row 0 - Col 9
Row 1 - Col 9
Row 2 - Col 9
Row 3 - Col 9
Row 4 - Col 9
Row 5 - Col 9
Row 6 - Col 9
Row 7 - Col 9
Row 8 - Col 9
Column 9

表头分组

正如这个示例,通过自定义表头渲染以将表头分组。

TIP

在这种情况下,我们使用了 JSX 功能,这个功能在playground上不被支持。 您可以在本地环境或在线集成开发环境(如 codesandbox )中试用它们。

建议您使用 JSX 使用您的表格组件,因为它包含 VNode 操作。

Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9
Row 0 - Col 10
Row 0 - Col 11
Row 0 - Col 12
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 1 - Col 10
Row 1 - Col 11
Row 1 - Col 12
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9
Row 2 - Col 10
Row 2 - Col 11
Row 2 - Col 12
Row 3 - Col 3
Row 3 - Col 4
Row 3 - Col 5
Row 3 - Col 6
Row 3 - Col 7
Row 3 - Col 8
Row 3 - Col 9
Row 3 - Col 10
Row 3 - Col 11
Row 3 - Col 12
Row 4 - Col 3
Row 4 - Col 4
Row 4 - Col 5
Row 4 - Col 6
Row 4 - Col 7
Row 4 - Col 8
Row 4 - Col 9
Row 4 - Col 10
Row 4 - Col 11
Row 4 - Col 12
Row 5 - Col 3
Row 5 - Col 4
Row 5 - Col 5
Row 5 - Col 6
Row 5 - Col 7
Row 5 - Col 8
Row 5 - Col 9
Row 5 - Col 10
Row 5 - Col 11
Row 5 - Col 12
Row 6 - Col 3
Row 6 - Col 4
Row 6 - Col 5
Row 6 - Col 6
Row 6 - Col 7
Row 6 - Col 8
Row 6 - Col 9
Row 6 - Col 10
Row 6 - Col 11
Row 6 - Col 12
Row 7 - Col 3
Row 7 - Col 4
Row 7 - Col 5
Row 7 - Col 6
Row 7 - Col 7
Row 7 - Col 8
Row 7 - Col 9
Row 7 - Col 10
Row 7 - Col 11
Row 7 - Col 12
Group width 400
Group width 400
Group width 200
Group width 200
Group width 200
Group width 200
Group width 200
Group width 200
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8
Column 9
Column 10
Column 11
Column 12
Row 0 - Col 0
Row 0 - Col 1
Row 0 - Col 2
Row 1 - Col 0
Row 1 - Col 1
Row 1 - Col 2
Row 2 - Col 0
Row 2 - Col 1
Row 2 - Col 2
Row 3 - Col 0
Row 3 - Col 1
Row 3 - Col 2
Row 4 - Col 0
Row 4 - Col 1
Row 4 - Col 2
Row 5 - Col 0
Row 5 - Col 1
Row 5 - Col 2
Row 6 - Col 0
Row 6 - Col 1
Row 6 - Col 2
Row 7 - Col 0
Row 7 - Col 1
Row 7 - Col 2
Group width 300
Group width 200
Group width 100
Column 0
Column 1
Column 2
Row 0 - Col 13
Row 0 - Col 14
Row 1 - Col 13
Row 1 - Col 14
Row 2 - Col 13
Row 2 - Col 14
Row 3 - Col 13
Row 3 - Col 14
Row 4 - Col 13
Row 4 - Col 14
Row 5 - Col 13
Row 5 - Col 14
Row 6 - Col 13
Row 6 - Col 14
Row 7 - Col 13
Row 7 - Col 14
Group width 200
Group width 200
Column 13
Column 14

过滤器

虚拟表格提供自定义页眉渲染器以创建自定义标题。 然后我们可以利用这些来渲染过滤器。

Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9
Row 1 - Col 2
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 2 - Col 2
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9
Row 3 - Col 2
Row 3 - Col 3
Row 3 - Col 4
Row 3 - Col 5
Row 3 - Col 6
Row 3 - Col 7
Row 3 - Col 8
Row 3 - Col 9
Row 4 - Col 2
Row 4 - Col 3
Row 4 - Col 4
Row 4 - Col 5
Row 4 - Col 6
Row 4 - Col 7
Row 4 - Col 8
Row 4 - Col 9
Row 5 - Col 2
Row 5 - Col 3
Row 5 - Col 4
Row 5 - Col 5
Row 5 - Col 6
Row 5 - Col 7
Row 5 - Col 8
Row 5 - Col 9
Row 6 - Col 2
Row 6 - Col 3
Row 6 - Col 4
Row 6 - Col 5
Row 6 - Col 6
Row 6 - Col 7
Row 6 - Col 8
Row 6 - Col 9
Row 7 - Col 2
Row 7 - Col 3
Row 7 - Col 4
Row 7 - Col 5
Row 7 - Col 6
Row 7 - Col 7
Row 7 - Col 8
Row 7 - Col 9
Row 8 - Col 2
Row 8 - Col 3
Row 8 - Col 4
Row 8 - Col 5
Row 8 - Col 6
Row 8 - Col 7
Row 8 - Col 8
Row 8 - Col 9
Column 2
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8
Column 9
Row 0 - Col 0
Row 0 - Col 1
Row 1 - Col 0
Row 1 - Col 1
Row 2 - Col 0
Row 2 - Col 1
Row 3 - Col 0
Row 3 - Col 1
Row 4 - Col 0
Row 4 - Col 1
Row 5 - Col 0
Row 5 - Col 1
Row 6 - Col 0
Row 6 - Col 1
Row 7 - Col 0
Row 7 - Col 1
Row 8 - Col 0
Row 8 - Col 1
Column 0
Column 1

可排序表格

您可以使用排序状态来对表格进行排序。

Row 0 - Col 0
Row 0 - Col 1
Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9
Row 1 - Col 0
Row 1 - Col 1
Row 1 - Col 2
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 2 - Col 0
Row 2 - Col 1
Row 2 - Col 2
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9
Row 3 - Col 0
Row 3 - Col 1
Row 3 - Col 2
Row 3 - Col 3
Row 3 - Col 4
Row 3 - Col 5
Row 3 - Col 6
Row 3 - Col 7
Row 3 - Col 8
Row 3 - Col 9
Row 4 - Col 0
Row 4 - Col 1
Row 4 - Col 2
Row 4 - Col 3
Row 4 - Col 4
Row 4 - Col 5
Row 4 - Col 6
Row 4 - Col 7
Row 4 - Col 8
Row 4 - Col 9
Row 5 - Col 0
Row 5 - Col 1
Row 5 - Col 2
Row 5 - Col 3
Row 5 - Col 4
Row 5 - Col 5
Row 5 - Col 6
Row 5 - Col 7
Row 5 - Col 8
Row 5 - Col 9
Row 6 - Col 0
Row 6 - Col 1
Row 6 - Col 2
Row 6 - Col 3
Row 6 - Col 4
Row 6 - Col 5
Row 6 - Col 6
Row 6 - Col 7
Row 6 - Col 8
Row 6 - Col 9
Row 7 - Col 0
Row 7 - Col 1
Row 7 - Col 2
Row 7 - Col 3
Row 7 - Col 4
Row 7 - Col 5
Row 7 - Col 6
Row 7 - Col 7
Row 7 - Col 8
Row 7 - Col 9
Row 8 - Col 0
Row 8 - Col 1
Row 8 - Col 2
Row 8 - Col 3
Row 8 - Col 4
Row 8 - Col 5
Row 8 - Col 6
Row 8 - Col 7
Row 8 - Col 8
Row 8 - Col 9
Column 0
Column 1
Column 2
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8
Column 9

受控的排序

您可以在需要时定义多个可排序的列。 请记住,当您在定义了多个可排序的列时, UI 可能会显得有些奇怪,因为用户不知道哪一列被排序。

Row 0 - Col 0
Row 0 - Col 1
Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9
Row 1 - Col 0
Row 1 - Col 1
Row 1 - Col 2
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 2 - Col 0
Row 2 - Col 1
Row 2 - Col 2
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9
Row 3 - Col 0
Row 3 - Col 1
Row 3 - Col 2
Row 3 - Col 3
Row 3 - Col 4
Row 3 - Col 5
Row 3 - Col 6
Row 3 - Col 7
Row 3 - Col 8
Row 3 - Col 9
Row 4 - Col 0
Row 4 - Col 1
Row 4 - Col 2
Row 4 - Col 3
Row 4 - Col 4
Row 4 - Col 5
Row 4 - Col 6
Row 4 - Col 7
Row 4 - Col 8
Row 4 - Col 9
Row 5 - Col 0
Row 5 - Col 1
Row 5 - Col 2
Row 5 - Col 3
Row 5 - Col 4
Row 5 - Col 5
Row 5 - Col 6
Row 5 - Col 7
Row 5 - Col 8
Row 5 - Col 9
Row 6 - Col 0
Row 6 - Col 1
Row 6 - Col 2
Row 6 - Col 3
Row 6 - Col 4
Row 6 - Col 5
Row 6 - Col 6
Row 6 - Col 7
Row 6 - Col 8
Row 6 - Col 9
Row 7 - Col 0
Row 7 - Col 1
Row 7 - Col 2
Row 7 - Col 3
Row 7 - Col 4
Row 7 - Col 5
Row 7 - Col 6
Row 7 - Col 7
Row 7 - Col 8
Row 7 - Col 9
Row 8 - Col 0
Row 8 - Col 1
Row 8 - Col 2
Row 8 - Col 3
Row 8 - Col 4
Row 8 - Col 5
Row 8 - Col 6
Row 8 - Col 7
Row 8 - Col 8
Row 8 - Col 9
Column 0
Column 1
Column 2
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8
Column 9

高亮显示鼠标悬停单元格

当处理一个大的列表时,很容易丢失当前行的轨迹和您正在访问的一列。 在这种情况下,使用这个功能可能很有帮助。

横跨列

虚拟化表格没有使用内置的 table 元素,故 colspanrowspanTableV1 比较略有不同。 然而,通过定制的行渲染器,这些功能仍然可以实现。 在本节中,我们将演示如何实现这一点。

Row 0 - Col 0
Row 0 - Col 1
Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9
Row 1 - Col 0
Row 1 - Col 1
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 2 - Col 0
Row 2 - Col 1
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9
Row 3 - Col 0
Row 3 - Col 1
Row 3 - Col 5
Row 3 - Col 6
Row 3 - Col 7
Row 3 - Col 8
Row 3 - Col 9
Row 4 - Col 0
Row 4 - Col 1
Row 4 - Col 2
Row 4 - Col 3
Row 4 - Col 4
Row 4 - Col 5
Row 4 - Col 6
Row 4 - Col 7
Row 4 - Col 8
Row 4 - Col 9
Row 5 - Col 0
Row 5 - Col 1
Row 5 - Col 3
Row 5 - Col 4
Row 5 - Col 5
Row 5 - Col 6
Row 5 - Col 7
Row 5 - Col 8
Row 5 - Col 9
Row 6 - Col 0
Row 6 - Col 1
Row 6 - Col 4
Row 6 - Col 5
Row 6 - Col 6
Row 6 - Col 7
Row 6 - Col 8
Row 6 - Col 9
Row 7 - Col 0
Row 7 - Col 1
Row 7 - Col 5
Row 7 - Col 6
Row 7 - Col 7
Row 7 - Col 8
Row 7 - Col 9
Row 8 - Col 0
Row 8 - Col 1
Row 8 - Col 2
Row 8 - Col 3
Row 8 - Col 4
Row 8 - Col 5
Row 8 - Col 6
Row 8 - Col 7
Row 8 - Col 8
Row 8 - Col 9
Column 0
Column 1
Column 2
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8
Column 9

纵跨行

既然我们已经覆盖了 Colspan,那我们也可以覆盖Row也是没问题的。 它与colspan略有不同,但是 的想法基本上是一样的。

Row 0 - Col 0
Row 0 - Col 1
Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9
Row 1 - Col 0
Row 1 - Col 1
Row 1 - Col 2
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 2 - Col 0
Row 2 - Col 1
Row 2 - Col 2
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9
Row 3 - Col 0
Row 3 - Col 1
Row 3 - Col 2
Row 3 - Col 3
Row 3 - Col 4
Row 3 - Col 5
Row 3 - Col 6
Row 3 - Col 7
Row 3 - Col 8
Row 3 - Col 9
Row 4 - Col 0
Row 4 - Col 1
Row 4 - Col 2
Row 4 - Col 3
Row 4 - Col 4
Row 4 - Col 5
Row 4 - Col 6
Row 4 - Col 7
Row 4 - Col 8
Row 4 - Col 9
Row 5 - Col 0
Row 5 - Col 1
Row 5 - Col 2
Row 5 - Col 3
Row 5 - Col 4
Row 5 - Col 5
Row 5 - Col 6
Row 5 - Col 7
Row 5 - Col 8
Row 5 - Col 9
Row 6 - Col 0
Row 6 - Col 1
Row 6 - Col 2
Row 6 - Col 3
Row 6 - Col 4
Row 6 - Col 5
Row 6 - Col 6
Row 6 - Col 7
Row 6 - Col 8
Row 6 - Col 9
Row 7 - Col 0
Row 7 - Col 1
Row 7 - Col 2
Row 7 - Col 3
Row 7 - Col 4
Row 7 - Col 5
Row 7 - Col 6
Row 7 - Col 7
Row 7 - Col 8
Row 7 - Col 9
Row 8 - Col 0
Row 8 - Col 1
Row 8 - Col 2
Row 8 - Col 3
Row 8 - Col 4
Row 8 - Col 5
Row 8 - Col 6
Row 8 - Col 7
Row 8 - Col 8
Row 8 - Col 9
Column 0
Column 1
Column 2
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8
Column 9

同时跨行和跨列

我们当然可以同时使用横跨列与纵跨行来满足您的业务需求!

Row 0 - Col 0
Row 0 - Col 1
Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 0 - Col 9
Row 1 - Col 1
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 1 - Col 9
Row 2 - Col 0
Row 2 - Col 1
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 2 - Col 9
Row 3 - Col 1
Row 3 - Col 5
Row 3 - Col 6
Row 3 - Col 7
Row 3 - Col 8
Row 3 - Col 9
Row 4 - Col 0
Row 4 - Col 1
Row 4 - Col 2
Row 4 - Col 3
Row 4 - Col 4
Row 4 - Col 5
Row 4 - Col 6
Row 4 - Col 7
Row 4 - Col 8
Row 4 - Col 9
Row 5 - Col 1
Row 5 - Col 3
Row 5 - Col 4
Row 5 - Col 5
Row 5 - Col 6
Row 5 - Col 7
Row 5 - Col 8
Row 5 - Col 9
Row 6 - Col 0
Row 6 - Col 1
Row 6 - Col 4
Row 6 - Col 5
Row 6 - Col 6
Row 6 - Col 7
Row 6 - Col 8
Row 6 - Col 9
Row 7 - Col 1
Row 7 - Col 5
Row 7 - Col 6
Row 7 - Col 7
Row 7 - Col 8
Row 7 - Col 9
Row 8 - Col 0
Row 8 - Col 1
Row 8 - Col 2
Row 8 - Col 3
Row 8 - Col 4
Row 8 - Col 5
Row 8 - Col 6
Row 8 - Col 7
Row 8 - Col 8
Row 8 - Col 9
Column 0
Column 1
Column 2
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8
Column 9

树形数据

虚拟表也可以在树状结构中呈现数据。 点击箭头图标,你可以展开或折叠树节点。

Row 0 - Col 2
Row 0 - Col 3
Row 0 - Col 4
Row 0 - Col 5
Row 0 - Col 6
Row 0 - Col 7
Row 0 - Col 8
Row 1 - Col 2
Row 1 - Col 3
Row 1 - Col 4
Row 1 - Col 5
Row 1 - Col 6
Row 1 - Col 7
Row 1 - Col 8
Row 2 - Col 2
Row 2 - Col 3
Row 2 - Col 4
Row 2 - Col 5
Row 2 - Col 6
Row 2 - Col 7
Row 2 - Col 8
Row 3 - Col 2
Row 3 - Col 3
Row 3 - Col 4
Row 3 - Col 5
Row 3 - Col 6
Row 3 - Col 7
Row 3 - Col 8
Row 4 - Col 2
Row 4 - Col 3
Row 4 - Col 4
Row 4 - Col 5
Row 4 - Col 6
Row 4 - Col 7
Row 4 - Col 8
Row 5 - Col 2
Row 5 - Col 3
Row 5 - Col 4
Row 5 - Col 5
Row 5 - Col 6
Row 5 - Col 7
Row 5 - Col 8
Row 6 - Col 2
Row 6 - Col 3
Row 6 - Col 4
Row 6 - Col 5
Row 6 - Col 6
Row 6 - Col 7
Row 6 - Col 8
Row 7 - Col 2
Row 7 - Col 3
Row 7 - Col 4
Row 7 - Col 5
Row 7 - Col 6
Row 7 - Col 7
Row 7 - Col 8
Row 8 - Col 2
Row 8 - Col 3
Row 8 - Col 4
Row 8 - Col 5
Row 8 - Col 6
Row 8 - Col 7
Row 8 - Col 8
Column 2
Column 3
Column 4
Column 5
Column 6
Column 7
Column 8
Row 0 - Col 0
Row 0 - Col 1
Row 1 - Col 0
Row 1 - Col 1
Row 2 - Col 0
Row 2 - Col 1
Row 3 - Col 0
Row 3 - Col 1
Row 4 - Col 0
Row 4 - Col 1
Row 5 - Col 0
Row 5 - Col 1
Row 6 - Col 0
Row 6 - Col 1
Row 7 - Col 0
Row 7 - Col 1
Row 8 - Col 0
Row 8 - Col 1
Column 0
Column 1
Row 0 - Col 9
Row 1 - Col 9
Row 2 - Col 9
Row 3 - Col 9
Row 4 - Col 9
Row 5 - Col 9
Row 6 - Col 9
Row 7 - Col 9
Row 8 - Col 9
Column 9

动态高度行

虚拟表能够呈现具有动态高度的行数。 如果您正在处理数据并不确定内容大小, 此功能对于调整到内容高度的渲染行是理想的。 要启用此功能,请传递 estimated-row-height 属性。 估计高度越接近实际内容,渲染体验就越顺。

TIP

每行高度在渲染过程中动态测量。 因此,如果您试图显示大量数据, UI 可能会 抖动。

Tom
Quaerat ipsam necessitatibus eum quibusdam est id voluptatem cumque mollitia.
Tom
Quaerat ipsam necessitatibus eum quibusdam est id voluptatem cumque mollitia.
Tom
Eius optio fugiat.
Tom
Eius optio fugiat.