ag-grid-如何通过上下文菜单从子网格获取父节点? [英] ag-grid - how to get parent node from child grid via context menu?

查看:307
本文介绍了ag-grid-如何通过上下文菜单从子网格获取父节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我有一个


但是如何从子视图中获取父节点数据


通过上下文菜单尝试过:


右键单击- getContextMenuItems 被执行,其输入为 params



在此示例中,child-grid没有任何行,并且 node i n context-params为null,可以,
,但是无论如何,至少应该通过grid API检索父详细信息,不是吗?



然后我尝试通过节点获取父级

,而不是 detail_173 ,因为您可以看到它的 ROOT_NODE_ID ,这对我来说很困惑。



所以问题是如何通过子视图上下文菜单或任何其他可能的方式(不存储临时值,则cuz多个孩子的)来获取父节点数据(以防万一的RecordID 173以防万一)可以同时打开)



是的,我已经阅读过此部分访问详细信息网格API ,但仍不清楚如何通过子网格获取父节点。 / p>

解决方案

一个非常可靠的解决方案是创建您自己的 detailCellRenderer



init 方法上:

  this .masterNode = params.node.parent; 

在创建明细网格时:

  detailGridOpions = {
...
onCellClicked:params => console.log(this.masterNode.data)
}

这是一个展示此功能的朋克:
https://next.plnkr.co/edit/8EIHpxQnlxsqe7EO

As an example, I have a Master\Detail grid.

Master\Detail defined as key-relation model and on getDetailRowData method parent node data exists in params

but how to get parent node data from child view?

Tried via context-menu:

On right click - getContextMenuItems got executed which has an input params

On this sample, child-grid doesn't have any row and node in context-params is null, it's ok, but anyway it should be possible to retrieve the parent details at least via grid API, isn't it ?

Then I've tried to get parent via node: but instead of detail_173 as you can see its ROOT_NODE_ID, and here is a confusion for me.

So question is that how to get parent node data (RecordID 173 just in case) through child-view context menu or any other possible way (without storing temp value, cuz multiple children's could be opened at the same time)

Yes, I've read this part Accessing Detail Grid API, and still unclear how to get parent-node via child-grid.

解决方案

A very reliable solution is to create your own detailCellRenderer.

on the init method:

this.masterNode = params.node.parent; 

when creating the detail grid:

detailGridOpions = {
    ...
    onCellClicked: params => console.log(this.masterNode.data)
}

Here is a plunker demonstrating this: https://next.plnkr.co/edit/8EIHpxQnlxsqe7EO

这篇关于ag-grid-如何通过上下文菜单从子网格获取父节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆