我使用带有自定义工具提示和按行过滤的ag网格创建了表格。假设默认网格有4行,行索引如下所示
row-index: 0
row-index: 1
row-index: 2
row-index: 3
在过滤行时,每当0,1,2时,行索引都会重置。我只需要恒定的行ID。
如何在农业网格自定义工具提示中获取行ID
import { Component } from '@angular/core';
import { ITooltipAngularComp } from 'ag-grid-angular';
@Component({
selector: 'tooltip-component',
templateUrl: './ag-grid-tooltip.component.html',
styleUrls: ['./ag-grid-tooltip.component.scss'],
})
export class AgGridTooltipComponent implements ITooltipAngularComp {
private params: any;
public data: string;
public show: boolean;
constructor() {
}
agInit(params): void {
this.params = params;
console.log(this.params.rowIndex); // working fine always starts with 0
console.log(this.params.rowId); // undefined
console.log(this.params.node.id); // can not read id.
}
}
答案 0 :(得分:0)
您需要像这样实现getRowNodeId函数。
gridOptions.getRowNodeId = (item) => {
return item.id;
};