【问题标题】:Not able to get row-id in ag-grid custom tooltip无法在 ag-grid 自定义工具提示中获取行 ID
【发布时间】:2020-01-09 18:03:58
【问题描述】:

我使用带有自定义工具提示和按行过滤的 ag 网格创建了表格。假设默认网格有 4 行,行索引如下所示

row-index: 0
row-index: 1
row-index: 2
row-index: 3

在过滤行时,行索引每次 0、1、2 时都会重置...我想要的只是行 ID,它是恒定的。

如何在ag grid自定义工具提示中获取row-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.



      }
    }

【问题讨论】:

    标签: angular ag-grid


    【解决方案1】:

    你需要像这样实现getRowNodeId函数。

    gridOptions.getRowNodeId = (item) => {
       return item.id;
    };
    

    【讨论】:

      猜你喜欢
      • 2020-05-14
      • 2019-07-03
      • 2020-08-12
      • 2020-09-23
      • 2021-04-27
      • 2020-05-30
      • 2020-12-02
      • 2020-01-02
      • 2018-07-05
      相关资源
      最近更新 更多