问题描述
例如,我有一个
但是如何从子视图中获取父节点数据?
右键单击- getContextMenuItems
被执行,其输入为 params
在此示例中,child-grid没有任何行,并且 node
i n context-params为null,可以,
,但是无论如何,至少应该通过grid API检索父详细信息,不是吗?
然后我尝试通过节点获取父级
:
,而不是 detail_173
,因为您可以看到它的 ROOT_NODE_ID
,这对我来说很困惑。
所以问题是如何通过子视图上下文菜单或任何其他可能的方式(不存储临时值,则cuz多个孩子的)来获取父节点数据(以防万一的RecordID 173以防万一)可以同时打开)
是的,我已经阅读过此部分,但仍不清楚如何通过子网格获取父节点。 / p>
一个非常可靠的解决方案是创建您自己的 detailCellRenderer 。
在 init
方法上:
this .masterNode = params.node.parent;
在创建明细网格时:
detailGridOpions = {
...
onCellClicked:params => console.log(this.masterNode.data)
}
这是一个展示此功能的朋克:
As an example, I have a Master\Detail grid.
but how to get parent node data from child view?
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-如何通过上下文菜单从子网格获取父节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!