Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/group #2074

Merged
merged 44 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7bb1cc2
feat: add tree merge cell in list-table
Rui-Sun Jul 11, 2024
66510ef
fix: fix enableTreeNodeMerge judgement in getCellMergeInfo()
Rui-Sun Jul 11, 2024
5fb01a9
feat: add groupBy config for listTable
Rui-Sun Jul 15, 2024
8ee0f87
Merge origin/develop into feat/group
Rui-Sun Jul 15, 2024
d77c5d2
feat: add group title style in theme
Rui-Sun Jul 16, 2024
fd7eb6a
feat: add getGroupTitleLevel in ListTable
Rui-Sun Jul 16, 2024
a38c68b
fix: fix async data problem in getCellStyle()
Rui-Sun Jul 16, 2024
44dfb1c
feat: add record update for list-table group
Rui-Sun Jul 16, 2024
a651809
test: update list-group demo
Rui-Sun Jul 17, 2024
87f10f2
chore: add rush update log
Rui-Sun Jul 17, 2024
efd8332
feat: add editor update in list-table gorup mode
Rui-Sun Jul 17, 2024
00bd28d
fix: fix defult groupTitleStyle in theme
Rui-Sun Jul 18, 2024
602ebf4
docs: add group function demo & docs
Rui-Sun Jul 18, 2024
b6325fa
feat: add collapse sync in group update
Rui-Sun Jul 19, 2024
c3ce3e6
feat: add tree merge cell in list-table
Rui-Sun Jul 11, 2024
147e0db
fix: fix enableTreeNodeMerge judgement in getCellMergeInfo()
Rui-Sun Jul 11, 2024
ef33109
feat: add groupBy config for listTable
Rui-Sun Jul 15, 2024
edba16c
feat: add group title style in theme
Rui-Sun Jul 16, 2024
cd4afb3
feat: add getGroupTitleLevel in ListTable
Rui-Sun Jul 16, 2024
8fe273c
fix: fix async data problem in getCellStyle()
Rui-Sun Jul 16, 2024
dfe97c8
feat: add record update for list-table group
Rui-Sun Jul 16, 2024
c324fba
test: update list-group demo
Rui-Sun Jul 17, 2024
8e92794
chore: add rush update log
Rui-Sun Jul 17, 2024
0f44c71
feat: add editor update in list-table gorup mode
Rui-Sun Jul 17, 2024
4c600ec
fix: fix defult groupTitleStyle in theme
Rui-Sun Jul 18, 2024
45504b7
docs: add group function demo & docs
Rui-Sun Jul 18, 2024
a6c4199
feat: add collapse sync in group update
Rui-Sun Jul 19, 2024
f0f0e76
feat: add groupTitleCustomLayout config in list-table
Rui-Sun Jul 19, 2024
73cc5f4
Merge branch 'feat/group' of https://github.com/VisActor/VTable into …
Rui-Sun Jul 19, 2024
32683f1
feat: add basic updateGroupTitle function
Rui-Sun Jul 22, 2024
06a47b4
feat: add stick cell update function
Rui-Sun Jul 24, 2024
80f16f2
feat: add ListTreeStickCellPlugin
Rui-Sun Jul 24, 2024
d98664b
feat: add ListTreeStickCellPlugin types
Rui-Sun Jul 25, 2024
ab30c9b
feat: change title judgement in ListTreeStickCellPlugin
Rui-Sun Jul 25, 2024
7abfb3e
feat: add update progress cell in ListTreeStickCellPlugin
Rui-Sun Jul 25, 2024
6d0c36b
feat: add basic interaction in ListTreeStickCellPlugin
Rui-Sun Jul 25, 2024
8ec0d5c
fix: fix clip range in listTreeStickCell mode
Rui-Sun Jul 29, 2024
6f8868d
fix: click jump function in ListTreeStickCellPlugin
Rui-Sun Jul 29, 2024
106d91b
fix: add hack rect name in ListTreeStickCellPlugin
Rui-Sun Jul 29, 2024
3035613
fix: fix groupBy problem in updateOption()
Rui-Sun Jul 31, 2024
b7a38aa
fix: fix merge cell size update problem
Rui-Sun Aug 2, 2024
419205e
fix: resize update in ListTreeStickCellPlugin
Rui-Sun Aug 2, 2024
92acc6c
docs: add demos and docs about group funtion
Rui-Sun Aug 2, 2024
3def017
Merge remote-tracking branch 'origin/develop' into feat/group
Rui-Sun Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions common/changes/@visactor/vtable/feat-group_2024-07-17-04-01.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "feat: add group function",
"type": "minor"
}
],
"packageName": "@visactor/vtable"
}
110 changes: 110 additions & 0 deletions docs/assets/demo/en/table-type/list-table-group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
category: examples
group: table-type
title: Basic table grouping display
cover: https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/preview/list-group.jpeg
order: 1-2
link: '../guide/table_type/List_table/group_list'
option: ListTable#groupBy
---

# Basic table grouping display

Basic table grouping display, used to display the hierarchical structure of grouping fields in data

## Key configuration

- groupBy: Specify the grouping field name

## Code demonstration

```javascript livedemo template=vtable
const titleColorPool = ['#3370ff', '#34c724', '#ff9f1a', '#ff4050', '#1f2329'];
let tableInstance;
fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American_Superstore_data.json')
.then(res => res.json())
.then(data => {
const columns = [
{
field: 'Order ID',
title: 'Order ID',
width: 'auto'
},
{
field: 'Customer ID',
title: 'Customer ID',
width: 'auto'
},
{
field: 'Product Name',
title: 'Product Name',
width: 'auto'
},
{
field: 'Category',
title: 'Category',
width: 'auto'
},
{
field: 'Sub-Category',
title: 'Sub-Category',
width: 'auto'
},
{
field: 'Region',
title: 'Region',
width: 'auto'
},
{
field: 'City',
title: 'City',
width: 'auto'
},
{
field: 'Order Date',
title: 'Order Date',
width: 'auto'
},
{
field: 'Quantity',
title: 'Quantity',
width: 'auto'
},
{
field: 'Sales',
title: 'Sales',
width: 'auto'
},
{
field: 'Profit',
title: 'Profit',
width: 'auto'
}
];

const option = {
records: data.slice(0, 100),
columns,
widthMode: 'standard',
groupBy: ['Category', 'Sub-Category'],
theme: VTable.themes.DEFAULT.extends({
groupTitleStyle: {
fontWeight: 'bold',
// bgColor: '#3370ff'
bgColor: args => {
const { col, row, table } = args;
const index = table.getGroupTitleLevel(col, row);
if (index !== undefined) {
return titleColorPool[index % titleColorPool.length];
}
}
}
})
};
tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
window.tableInstance = tableInstance;
})
.catch(e => {
console.error(e);
});
```
15 changes: 11 additions & 4 deletions docs/assets/demo/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
"en": "List Table Tree(lazy load)"
}
},
{
"path": "list-table-group",
"title": {
"zh": "基本表格分组展示",
"en": "List Table Group"
}
},
{
"path": "transpose-table",
"title": {
Expand Down Expand Up @@ -1285,15 +1292,15 @@
{
"path": "table-export-ignore-icon",
"title": {
"zh": "表格导出",
"en": "table export"
"zh": "表格导出(忽略图标)",
"en": "table export(ignore-icon)"
}
},
{
"path": "table-export-format",
"title": {
"zh": "表格导出",
"en": "table export"
"zh": "表格导出(格式化)",
"en": "table export(format)"
}
}
]
Expand Down
110 changes: 110 additions & 0 deletions docs/assets/demo/zh/table-type/list-table-group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
category: examples
group: table-type
title: 基本表格分组展示
cover: https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/preview/list-group.jpeg
order: 1-2
link: '../guide/table_type/List_table/group_list'
option: ListTable#groupBy
---

# 基本表格分组展示

基本表格分组展示,用于展示数据中分组字段的层级结构

## 关键配置

- groupBy: 指定分组字段名称

## 代码演示

```javascript livedemo template=vtable
const titleColorPool = ['#3370ff', '#34c724', '#ff9f1a', '#ff4050', '#1f2329'];
let tableInstance;
fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American_Superstore_data.json')
.then(res => res.json())
.then(data => {
const columns = [
{
field: 'Order ID',
title: 'Order ID',
width: 'auto'
},
{
field: 'Customer ID',
title: 'Customer ID',
width: 'auto'
},
{
field: 'Product Name',
title: 'Product Name',
width: 'auto'
},
{
field: 'Category',
title: 'Category',
width: 'auto'
},
{
field: 'Sub-Category',
title: 'Sub-Category',
width: 'auto'
},
{
field: 'Region',
title: 'Region',
width: 'auto'
},
{
field: 'City',
title: 'City',
width: 'auto'
},
{
field: 'Order Date',
title: 'Order Date',
width: 'auto'
},
{
field: 'Quantity',
title: 'Quantity',
width: 'auto'
},
{
field: 'Sales',
title: 'Sales',
width: 'auto'
},
{
field: 'Profit',
title: 'Profit',
width: 'auto'
}
];

const option = {
records: data.slice(0, 100),
columns,
widthMode: 'standard',
groupBy: ['Category', 'Sub-Category'],
theme: VTable.themes.DEFAULT.extends({
groupTitleStyle: {
fontWeight: 'bold',
// bgColor: '#3370ff'
bgColor: args => {
const { col, row, table } = args;
const index = table.getGroupTitleLevel(col, row);
if (index !== undefined) {
return titleColorPool[index % titleColorPool.length];
}
}
}
})
};
tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
window.tableInstance = tableInstance;
})
.catch(e => {
console.error(e);
});
```
120 changes: 120 additions & 0 deletions docs/assets/guide/en/table_type/List_table/group_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
## Basic table grouping display

In this tutorial, we will learn how to use the basic table grouping display function in VTable.

## Usage scenario

The basic table grouping display function is applicable to a variety of scenarios, such as:

- Financial statements: You can group and display according to different account types (such as income, expenditure, assets, liabilities) to help you understand the financial situation more clearly.

- Sales data analysis: You can group by product category, region, salesperson, etc., to facilitate comparison and analysis of sales performance in different categories or regions.

- Project management: You can group by project stage, responsible team, priority, etc. to help better track and manage project progress.

- Human resource management: You can group by department, position, years of work, etc. to facilitate employee management and performance evaluation.

## Usage method

In the option of ListTable, configure the `groupBy` field, the value is the grouping field name, you can configure a single field, or you can configure an array of multiple fields.
```
{
// ...
groupBy: 'key',
}
```
```
{
// ...
groupBy: ['key1', 'key2'],
}
```
## Example
```javascript livedemo template=vtable
const records = [
{
name: 'John Smith',
position: 'Recruiting Manager',
salary: '$8000',
group: 'Recruiting Group'
},
{
name: 'Emily Johnson',
position: 'Recruiting Supervisor',
salary: '$6000',
group: 'Recruiting Group'
},
{
name: 'Michael Davis',
position: 'Recruiting Specialist',
salary: '$4000',
group: 'Recruiting Group'
},
{
name: 'Jessica Brown',
position: 'Training Manager',
salary: '$8000',
group: 'Training Group',
},
{
name: 'Andrew Wilson',
position: 'Training Supervisor',
salary: '$6000',
group: 'Training Group',
}
];
const columns = [
{
field: 'name',
title: 'Name',
width: 'auto',
},
{
field: 'position',
title: 'Position',
width: 'auto',
},
{
field: 'salary',
title: 'Salary',
width: 'auto',
},
];

const option = {
records,
columns,
widthMode: 'standard',
groupBy: 'group'
};
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
window['tableInstance'] = tableInstance;
```

## Specify the display style of the group title

In the theme, you can configure the groupTitleStyle property to specify the display style of the group title. If you need to specify the style of group titles at different levels, you can use the function to get the level of the current node through the `table.getGroupTitleLevel(col, row)` method to specify the styles of different levels.

```ts
const option: VTable.ListTableConstructorOptions = {
// ...
groupBy: ['Category', 'Sub-Category'],
theme: VTable.themes.DEFAULT.extends({
groupTitleStyle: {
fontWeight: 'bold',
bgColor: args => {
const { col, row, table } = args;
const index = table.getGroupTitleLevel(col, row); // Get the level of the current node
if (index !== undefined) {
return titleColorPool[index % titleColorPool.length];
}
}
}
})
};
```

<div style="width: 80%; text-align: center;">
<img src="https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/preview/list-group.jpeg" />
</div>
Loading
Loading