Skip to content

Commit

Permalink
Merge pull request #2894 from VisActor/docs/list-table-hierarchyExpan…
Browse files Browse the repository at this point in the history
…dLevel

Docs/list table hierarchy expand level
  • Loading branch information
fangsmile authored Nov 22, 2024
2 parents d47d5da + 409f02f commit 70e30e4
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "refactor: when set headerSelectMode body drag column order should work #2860\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "892739385@qq.com"
}
34 changes: 17 additions & 17 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion docs/assets/guide/en/table_type/List_table/tree_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,22 @@ const records = [
];
```
## Default expansion level of tree structure
In a tree structure, the default expansion level can be specified through the `hierarchyExpandLevel` configuration item.
For example, to specify the default expansion to the third level: `hierarchyExpandLevel: 3`
```javascript
const option = {
records,
columns,
widthMode: 'standard',
hierarchyExpandLevel: 3
};
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
```
## Lazy loading of child node data scenarios
In some scenarios, the child node data may be relatively large. In view of the excessive performance pressure on the backend database, and you do not want to obtain all the data at once, you need to call the interface to load the data when you click to expand. Then you can use the following method to achieve:
Expand Down Expand Up @@ -304,4 +320,4 @@ const option = {
};
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
window['tableInstance'] = tableInstance;
```
```
20 changes: 18 additions & 2 deletions docs/assets/guide/zh/table_type/List_table/tree_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ const records = [
];
```
## 树形结构的默认展开层级
在树形结构中,默认展开的层级可以通过`hierarchyExpandLevel`配置项来指定。
例如指定默认展开到第三层级:`hierarchyExpandLevel: 3`
```javascript
const option = {
records,
columns,
widthMode: 'standard',
hierarchyExpandLevel: 3
};
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
```
## 懒加载子节点数据场景
在一些场景下,子节点数据可能比较大,鉴于后台数据库性能压力过大,并不想一次性获取到全部数据,需要在点击展开时才进行调用接口来加载数据。那么可以使用如下方式来实现:
Expand All @@ -186,7 +202,7 @@ const records = [
## 合并父节点
在一些场景中,希望父节点整行作为一个合并单元格显示,可以在数据中,配置`vtableMerge``vtableMergeName`,其中`vtableMerge`为 true 时,表示该父节点为合并单元格,`vtableMergeName`为合并单元格中显示的名称;同时,需要在option中加入`enableTreeNodeMerge`配置为 true。
在一些场景中,希望父节点整行作为一个合并单元格显示,可以在数据中,配置`vtableMerge``vtableMergeName`,其中`vtableMerge`为 true 时,表示该父节点为合并单元格,`vtableMergeName`为合并单元格中显示的名称;同时,需要在 option 中加入`enableTreeNodeMerge`配置为 true。
```javascript livedemo template=vtable
const records = [
Expand Down Expand Up @@ -305,4 +321,4 @@ const option = {
};
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
window['tableInstance'] = tableInstance;
```
```
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@visactor/vtable-export": "workspace:*",
"@visactor/vtable-search": "workspace:*",
"buble": "^0.20.0",
"@visactor/vchart": "1.12.11",
"@visactor/vchart": "1.12.12",
"markdown-it": "^13.0.0",
"highlight.js": "^11.8.0",
"axios": "^1.4.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/openinula-vtable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@visactor/vutils": "~0.18.14"
},
"devDependencies": {
"@visactor/vchart": "1.12.11",
"@visactor/vchart": "1.12.12",
"@internal/bundler": "workspace:*",
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
Expand Down Expand Up @@ -93,4 +93,4 @@
"peerDependencies": {
"openinula": "~0.1.2-SNAPSHOT"
}
}
}
4 changes: 2 additions & 2 deletions packages/react-vtable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"react-reconciler": "0.29.2"
},
"devDependencies": {
"@visactor/vchart": "1.12.11",
"@visactor/vchart": "1.12.12",
"@internal/bundler": "workspace:*",
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
Expand Down Expand Up @@ -101,4 +101,4 @@
"@arco-design/web-react": "2.60.2",
"@types/react-reconciler": "0.28.8"
}
}
}
4 changes: 2 additions & 2 deletions packages/vtable-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"exceljs": "4.4.0"
},
"devDependencies": {
"@visactor/vchart": "1.12.11",
"@visactor/vchart": "1.12.12",
"@internal/bundler": "workspace:*",
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
Expand Down Expand Up @@ -87,4 +87,4 @@
"@types/react-is": "^17.0.3",
"rollup-plugin-node-resolve": "5.2.0"
}
}
}
4 changes: 2 additions & 2 deletions packages/vtable-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@visactor/vutils": "~0.18.14"
},
"devDependencies": {
"@visactor/vchart": "1.12.11",
"@visactor/vchart": "1.12.12",
"@internal/bundler": "workspace:*",
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
Expand Down Expand Up @@ -83,4 +83,4 @@
"@types/react-is": "^17.0.3",
"rollup-plugin-node-resolve": "5.2.0"
}
}
}
4 changes: 2 additions & 2 deletions packages/vtable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"devDependencies": {
"luxon": "*",
"@visactor/vchart": "1.12.11",
"@visactor/vchart": "1.12.12",
"@internal/bundler": "workspace:*",
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
Expand Down Expand Up @@ -127,4 +127,4 @@
"url": "https://github.com/VisActor/VTable.git",
"directory": "packages/vtable"
}
}
}
5 changes: 5 additions & 0 deletions packages/vtable/src/core/BaseTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ import { createReactContainer } from '../scenegraph/layout/frozen-react';
import { setIconColor } from '../icons';
import { TableAnimationManager } from './animation';
import type { ITableAnimationOption } from '../ts-types/animation/appear';
import { checkCellInSelect } from '../state/common/check-in-select';

const { toBoxArray } = utilStyle;
const { isTouchEvent } = event;
Expand Down Expand Up @@ -3284,6 +3285,10 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
if (
this.isHeader(col, row) &&
(this.stateManager.isSelected(col, row) ||
(this.options.select?.headerSelectMode === 'body' &&
checkCellInSelect(col, row, [
this.getCellRange(this.stateManager.select.cellPos.col, this.stateManager.select.cellPos.row)
])) ||
this.options.select?.disableHeaderSelect ||
this.options.select?.disableSelect)
) {
Expand Down
8 changes: 4 additions & 4 deletions packages/vtable/src/event/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,10 @@ export class EventManager {
const { eventArgs } = eventArgsSet;
if (
eventArgs &&
this.table.isHeader(eventArgs.col, eventArgs.row) &&
(checkCellInSelect(eventArgs.col, eventArgs.row, this.table.stateManager.select.ranges) ||
this.table.options.select?.disableHeaderSelect ||
this.table.options.select?.disableSelect) &&
// this.table.isHeader(eventArgs.col, eventArgs.row) &&
// (checkCellInSelect(eventArgs.col, eventArgs.row, this.table.stateManager.select.ranges) ||
// this.table.options.select?.disableHeaderSelect ||
// this.table.options.select?.disableSelect) &&
// this.table.stateManager.select.cellPosStart.col === eventArgs.col &&
// this.table.stateManager.select.cellPosStart.row === eventArgs.row &&
this.table._canDragHeaderPosition(eventArgs.col, eventArgs.row)
Expand Down
2 changes: 0 additions & 2 deletions packages/vtable/src/state/hover/row.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { Scenegraph } from '../../scenegraph/scenegraph';
import type { CellRange, HighlightScope } from '../../ts-types';
import { CellPosition } from '../../ts-types';
import { checkCellInSelect, checkRowInlineInSelect } from '../common/check-in-select';
import { updateCell } from './update-cell';

export function clearRowHover(
Expand Down
2 changes: 0 additions & 2 deletions packages/vtable/src/state/hover/single.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { Scenegraph } from '../../scenegraph/scenegraph';
import type { CellRange, HighlightScope } from '../../ts-types';
import { CellPosition } from '../../ts-types';
import { checkCellInSelect, checkColInlineInSelect, checkRowInlineInSelect } from '../common/check-in-select';
import { updateCell } from './update-cell';

export function clearSingleHover(
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-vtable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"devDependencies": {
"@arco-design/web-vue": "^2.11.0",
"cross-env": "^7.0.3",
"@visactor/vchart": "1.12.11",
"@visactor/vchart": "1.12.12",
"@internal/bundler": "workspace:*",
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
Expand Down Expand Up @@ -97,4 +97,4 @@
"eslint-plugin-vue": "^9.26.0",
"vue-eslint-parser": "^9.4.2"
}
}
}

0 comments on commit 70e30e4

Please sign in to comment.