首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法在ag-grid自定义工具提示中获得行id。

无法在ag-grid自定义工具提示中获得行id。
EN

Stack Overflow用户
提问于 2020-01-09 09:51:20
回答 1查看 347关注 0票数 0

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

代码语言:javascript
运行
复制
row-index: 0
row-index: 1
row-index: 2
row-index: 3

在过滤行时,行索引每次重置0、1、2.我只想要行id,它是常量的。

如何在ag网格自定义工具提示中获取行id

代码语言:javascript
运行
复制
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.



      }
    }
EN

回答 1

Stack Overflow用户

发布于 2020-01-09 10:03:58

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

代码语言:javascript
运行
复制
gridOptions.getRowNodeId = (item) => {
   return item.id;
};
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59661265

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档