mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
fix: 修复 table2 树形数据展示对应错误问题 (#9876)
This commit is contained in:
parent
fcf57cf8c6
commit
b36586253b
@ -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];
|
||||
}
|
||||
|
@ -1384,7 +1384,7 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
||||
// 但直接使用amis-ui的table,render方法一般直接返回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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user