fix: 修复 table2 树形数据展示对应错误问题 (#9876)

This commit is contained in:
liaoxuezhi 2024-03-26 11:31:35 +08:00 committed by GitHub
parent fcf57cf8c6
commit b36586253b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 4 deletions

View File

@ -282,8 +282,10 @@ export const TableStore2 = ServiceStore.named('TableStore2')
function getRowByIndex(rowIndex: number, levels?: Array<string>): IRow2 {
if (levels && levels.length > 0) {
levels = levels.concat();
const index = +(levels.shift() || 0);
return getRowByIndex(index, levels);
const host = getRowByIndex(index, levels)?.children;
return host?.[rowIndex];
}
return self.rows[rowIndex];
}

View File

@ -1384,7 +1384,7 @@ export class Table extends React.PureComponent<TableProps, TableState> {
// 但直接使用amis-ui的tablerender方法一般直接返回ReactElement
const render =
item.render && typeof item.render === 'function'
? item.render(data[item.name], data, rowIndex, i)
? item.render(data[item.name], data, rowIndex, i, levels)
: null;
let props = {rowSpan: 1, colSpan: 1};
let children = render;

View File

@ -818,10 +818,11 @@ export default class Table2 extends React.Component<Table2Props, object> {
text: string,
record: any,
rowIndex: number,
colIndex: number
colIndex: number,
levels: Array<string>
) => {
const props: RenderProps = {};
const item = store.getRowByIndex(rowIndex) || {};
const item = store.getRowByIndex(rowIndex, levels) || {};
const obj = {
children: this.renderCellSchema(column, {
data: item.locals,