Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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,11 @@
{
"changes": [
{
"comment": "fix: masterSubTable plugin setRecordChildren fetches wrong record after sorting\n\n",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "892739385@qq.com"
}
17 changes: 5 additions & 12 deletions packages/vtable-plugins/src/master-detail-plugin/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { EventManager } from './events';
import { SubTableManager } from './subtable';
import { TableAPIExtensions } from './table-api-extensions';
import { bindMasterDetailCheckboxChange } from './checkbox';

import type { pluginsDefinition } from '@visactor/vtable';
/**
* 主从表插件核心类
*/
export class MasterDetailPlugin implements VTable.plugins.IVTablePlugin {
export class MasterDetailPlugin implements pluginsDefinition.IVTablePlugin {
id = `Master Detail Plugin`;
name = 'Master Detail Plugin';
runTime = [
Expand Down Expand Up @@ -564,17 +564,10 @@ export class MasterDetailPlugin implements VTable.plugins.IVTablePlugin {
* 设置记录的子数据并展开
*/
setRecordChildren(children: unknown[], col: number, row: number): void {
// 获取原始记录数据
const recordIndex = this.table.getRecordIndexByCell(col, row);
if (recordIndex === undefined || recordIndex === null) {
console.warn('Invalid row, cannot get record index');
return;
}

const realRecordIndex = typeof recordIndex === 'number' ? recordIndex : recordIndex[0];
const record = this.table.dataSource.get(realRecordIndex);
// 获取当前单元格对应的源数据记录,避免排序后索引不一致 #4986
const record = this.table.getCellOriginRecord(col, row);
if (!record) {
console.warn('Cannot find record for index:', realRecordIndex);
console.warn('Cannot find record for cell:', col, row);
return;
}

Expand Down
Loading