如果仅知道该特定行中的唯一数据,如何关注 agGrid(angular) 中的特定行?

How to focus on a particular row in agGrid(angular),If only the unique data in that particular row is only known?

我有一个 agGrid,其中一些数据有两行作为唯一键: id, name, address, status 这些是我的专栏,其中 name and status 是唯一的。 如果我知道 name and status,我如何才能在页面重新加载时专注于特定行。

我尝试获取该特定行的 rowIndex,但未获取该行的 rowId。

this.gridOptions.getRowNodeId = function(data) {
  return data.id
};
var rowNode = this.gridOptions.api.getRowNode('x');
rowNode.setSelected(true);

我将如何得到这个 data.id 和 x 只有 name and status 值已知?

请帮我找到解决办法。 提前谢谢你。

您做对了,但是由于您在检索 rowNode 时不知道 id,因此使用 name+status 定义一个键将很有用,因为它也是唯一的。

首先,您需要向您的网格提供getRowNodeId()

由于名称 + 状态组合是唯一的,我告诉网格将其用作键

gridOptions.getRowNodeId = function(data) {
    return data.name + '_' + data.status;
};

既然你已经知道了名称和状态的值,我就这样做

var rowNode = this.gridOptions.api.getRowNode("name_status"); //pass your known name_status

rowNode.setSelected(true);