如何解决泳道/ngx-datatable,我怎样才能踢细胞类功能?
当组件属性更改时,不会调用 cellClass
函数。
我如何踢rowClass
或cellClass
?
@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];
如果你使用的是store,则需要取消immutable属性。
示例
@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);
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。