泳道/ngx-datatable,我如何踢cellClass函数?



组件属性改变时不调用cellClass函数

如何踢rowClasscellClass?

@Component({
...,
template: `<ngx-datatable [rowClass]="rowClass"></ngx-datatable>`
})
class SomeComponent {
someVariable = true;
rowClass = (row) => {
return {
'some-class': (() => { return this.someVariable === row.someVariable })()
};
}
}

相关https://github.com/swimlane/ngx-datatable/issues/774

我可以通过改变this.rows来解决这个问题。

https://swimlane.gitbook.io/ngx-datatable/cd

this.rows = [...this.rows];

如果您正在使用存储,则需要取消不可变属性。

例子
@Input() set list(list: Record<string, unknown>[]) {
if (list.length) {
// If the search results are reflected in the table.
// And 20 items are loaded at a time.
if (list.length === 20) {
this.rows = list.map((item) => ({ ...item }));
// Load more items
} else {
const newRows = list.map((item) => ({ ...item })).slice(this.rows.length);
this.rows = this.rows.concat(newRows);
}
}
}

最新更新