如何在ag-grid中获取该行的DOM元素?
this.gridOptions.api.getRowNode(id)
这样可以获取一行对象。但是如何获取此行的DOM?
答案 0 :(得分:0)
正确的解决方案:
constructor(public myElement: ElementRef) { }
this.gridOptions = <GridOptions> {
...
};
ngAfterViewInit() {
const countOfRows = this.gridOptions.api.getDisplayedRowCount();
for (let i = 0; i < countOfRows; i++) {
const elements = this.myElement.nativeElement.querySelectorAll(`[row-index="${i}"]`);
const row = elements[1];
row.addEventListener('dragover', function() {
row.style.backgroundColor = 'yellow';
});
}
}