fix: table2 rowClassName兼容数据替换场景 (#7678)

Co-authored-by: wanglinfang <wanglinfang@baidu.com>
This commit is contained in:
wanglinfang2014 2023-08-03 10:30:27 +08:00 committed by GitHub
parent b2637905fa
commit d933aeb4a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -442,7 +442,7 @@ export const TableStore2 = ServiceStore.named('TableStore2')
function exchange(fromIndex: number, toIndex: number, item?: IRow2) {
item = item || self.rows[fromIndex];
if (item.parentId) {
if (item?.parentId) {
const parent: IRow2 = self.getRowById(item.parentId) as any;
const offset = parent.children.indexOf(item) - fromIndex;
toIndex += offset;

View File

@ -1591,11 +1591,13 @@ export default class Table2 extends React.Component<Table2Props, object> {
if (rowClassNameExpr) {
classnames.push(filter(rowClassNameExpr, {record, rowIndex}));
}
// row可能不存在
// 比如初始化给了10条数据异步接口又替换成4条
const row = store.getRowByIndex(rowIndex);
if (row.modified) {
if (row?.modified) {
classnames.push('is-modified');
}
if (row.moved) {
if (row?.moved) {
classnames.push('is-moved');
}
return classnames.join(' ');