Javascript 如何在NGX数据表中动态设置行类?
我基本上实现了一个表外的搜索功能,如果搜索内容与表行中的内容匹配,我希望突出显示行。 页面上还有多个表 这是我的面板组件Javascript 如何在NGX数据表中动态设置行类?,javascript,angular,ngx-datatable,Javascript,Angular,Ngx Datatable,我基本上实现了一个表外的搜索功能,如果搜索内容与表行中的内容匹配,我希望突出显示行。 页面上还有多个表 这是我的面板组件 <app-mystuff-dashboard-panel *ngFor="let group of initialGroupedSearchResults | objectFilter: { MyContentSetScope: 'Private', MyContentSetType : 'System', contentSetName: 'Clipboard' } |
<app-mystuff-dashboard-panel *ngFor="let group of initialGroupedSearchResults | objectFilter: { MyContentSetScope: 'Private', MyContentSetType : 'System', contentSetName: 'Clipboard' } | orderBy: 'contentSetName'"
[contentSet]="group"
[searchText]="searchText"></app-mystuff-dashboard-panel>
此函数中的行参数大部分未定义。另外,我在大约3个表上有大约100行,当searchText更改时,对于合并的3个表,这个getRowClass函数仅激发大约5次
我曾经尝试过一次又一次地重新渲染表,但效果并不理想
if ((changes.searchText && (changes.searchText.currentValue !== changes.searchText.previousValue))) {
console.log(this.searchText);
this.items = this.items.slice();
this.items = [...this.items];
this.items.push({});
this.items.splice(-1, 1);1
this.items = [...this.items];
this.changeDetector.detectChanges();
}
你能试着调用
this.rows=this.rows.slice()吗代码>方法。这将把rows变量设置为它自己的副本。所以ngx数据表可能会重新呈现。@MidhunDarvin我试过了。不起作用..我也试过这个。行=[…这个。行]好的。你能试试这个:this.items.push({});this.items=[…this.items];此项。拼接(-1,1);this.items=[…this.items]代码>
if ((changes.searchText && (changes.searchText.currentValue !== changes.searchText.previousValue))) {
console.log(this.searchText);
this.items = this.items.slice();
this.items = [...this.items];
this.items.push({});
this.items.splice(-1, 1);1
this.items = [...this.items];
this.changeDetector.detectChanges();
}