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

fix: fix select all in row-series-number checkbox #2880 #2898

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "fix: fix select all in row-series-number checkbox #2880",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
15 changes: 9 additions & 6 deletions packages/vtable/src/layout/simple-header-layout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable sort-imports */
import { isValid } from '@visactor/vutils';
import { isValid, merge } from '@visactor/vutils';
import type { ListTable } from '../ListTable';
import { DefaultSparklineSpec } from '../tools/global';
import type {
Expand Down Expand Up @@ -104,17 +104,17 @@ export class SimpleHeaderLayoutMap implements LayoutMapAPI {
handleRowSeriesNumber(rowSeriesNumber: IRowSeriesNumber) {
if (rowSeriesNumber) {
if (Array.isArray(rowSeriesNumber)) {
this.rowSeriesNumberColumn = rowSeriesNumber.map(seriesNumber => {
this.rowSeriesNumberColumn = rowSeriesNumber.map((seriesNumber, index) => {
return {
id: this.seqId++,
title: seriesNumber.title,
define: seriesNumber,
define: merge({ field: '_vtable_rowSeries_number_' + index }, seriesNumber),
cellType: seriesNumber.cellType ?? 'text',
headerType: rowSeriesNumber.cellType ?? 'text',
style: seriesNumber.style,
width: seriesNumber.width,
format: seriesNumber.format,
field: seriesNumber.field,
field: seriesNumber.field ?? '_vtable_rowSeries_number_' + index,
icon: seriesNumber.icon,
headerIcon: seriesNumber.headerIcon,
isChildNode: false
Expand All @@ -125,13 +125,13 @@ export class SimpleHeaderLayoutMap implements LayoutMapAPI {
{
id: this.seqId++,
title: rowSeriesNumber.title,
define: rowSeriesNumber,
define: merge({ field: '_vtable_rowSeries_number' }, rowSeriesNumber),
cellType: rowSeriesNumber.cellType ?? 'text',
headerType: rowSeriesNumber.cellType ?? 'text',
style: rowSeriesNumber.style,
width: rowSeriesNumber.width,
format: rowSeriesNumber.format,
field: '', //rowSeriesNumber.field,
field: '_vtable_rowSeries_number', //rowSeriesNumber.field,
icon: rowSeriesNumber.icon,
headerIcon: rowSeriesNumber.headerIcon,
isChildNode: false
Expand Down Expand Up @@ -865,6 +865,9 @@ export class SimpleHeaderLayoutMap implements LayoutMapAPI {
return this._headerObjectMap[id as number]!;
}
getHeaderField(col: number, row: number) {
if (this.isSeriesNumberInHeader(col, row)) {
return this.getSeriesNumberHeader(col, row)?.field;
}
const id = this.getCellId(col, row);
return (
this._headerObjectMap[id as number]?.field ||
Expand Down
14 changes: 14 additions & 0 deletions packages/vtable/src/state/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ export function initCheckedState(records: any[], state: StateManager) {
}
}
});

// for row series number
if (state.table.leftRowSeriesNumberCount === 1) {
state.headerCheckedState._vtable_rowSeries_number = false;
state._checkboxCellTypeFields.push('_vtable_rowSeries_number');
isNeedInitHeaderCheckedStateFromRecord = true;
} else if (state.table.leftRowSeriesNumberCount > 1) {
for (let i = 0; i < state.table.leftRowSeriesNumberCount; i++) {
state.headerCheckedState[`_vtable_rowSeries_number_${i}`] = false;
state._checkboxCellTypeFields.push(`_vtable_rowSeries_number_${i}`);
}
isNeedInitHeaderCheckedStateFromRecord = true;
}

//如果没有明确指定check的状态 遍历所有数据获取到节点状态 确定这个header的check状态
if (isNeedInitHeaderCheckedStateFromRecord) {
records.forEach((record: any, index: number) => {
Expand Down
Loading