diff --git a/common/changes/@visactor/vtable/fix-sortState-fieldUndefined-error_2024-11-07-14-50.json b/common/changes/@visactor/vtable/fix-sortState-fieldUndefined-error_2024-11-07-14-50.json new file mode 100644 index 000000000..f966c7841 --- /dev/null +++ b/common/changes/@visactor/vtable/fix-sortState-fieldUndefined-error_2024-11-07-14-50.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: sortState field undefined occor error\n\n", + "type": "none", + "packageName": "@visactor/vtable" + } + ], + "packageName": "@visactor/vtable", + "email": "892739385@qq.com" +} \ No newline at end of file diff --git a/packages/vtable/src/ListTable.ts b/packages/vtable/src/ListTable.ts index 9e28ca1bc..cf60f7c8b 100644 --- a/packages/vtable/src/ListTable.ts +++ b/packages/vtable/src/ListTable.ts @@ -1112,8 +1112,10 @@ export class ListTable extends BaseTable implements ListTableAPI { //重复逻辑抽取updateWidthHeight if (sort !== undefined) { - this.internalProps.sortState = this.internalProps.multipleSort ? (Array.isArray(sort) ? sort : [sort]) : sort; - this.stateManager.setSortState((this as any).sortState as SortState); + if ((!Array.isArray(sort) && isValid(sort.field)) || Array.isArray(sort)) { + this.internalProps.sortState = this.internalProps.multipleSort ? (Array.isArray(sort) ? sort : [sort]) : sort; + this.stateManager.setSortState((this as any).sortState as SortState); + } } if (records) { _setRecords(this, records); diff --git a/packages/vtable/src/state/state.ts b/packages/vtable/src/state/state.ts index 1c1cb5cc3..2859311f3 100644 --- a/packages/vtable/src/state/state.ts +++ b/packages/vtable/src/state/state.ts @@ -519,15 +519,15 @@ export class StateManager { prev.push({ field: item.field, order: item.order, - row: column.startInTotal + this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount ?? 0, - col: column.level + row: column?.startInTotal + this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount ?? 0, + col: column?.level } as any); } else { prev.push({ field: item.field, order: item.order, - col: column.startInTotal + this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount ?? 0, - row: column.level + col: column?.startInTotal + this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount ?? 0, + row: column?.level } as any); }