如何在extjs小部件列中获取rowIndex [英] How to get rowIndex in extjs widget column
问题描述
我需要一个小部件列中的按钮来在ExtJS 6 panel.grid中了解其rowIndex,以便在按钮上单击它可以使用该功能。我知道我可以从渲染器函数中拉出这些信息,但这似乎在按钮被创建之前执行。任何有关如何获取索引的想法?
I need a button in a widget column to know its rowIndex in an ExtJS 6 panel.grid, so that on button click it can use that functionality. I know I can pull that information from the renderer function, but that seems to execute before the button has been created. Any ideas on how I can get the index?
推荐答案
使用 indexOf
在 gridview
上。您需要将节点
作为参数传递,该参数是表示行的HTML元素。在Ext JS 6中,网格行是HTML表格,因此可以从按钮元素 b
中找到按钮的行元素作为 b.el.up( '表')
。 gridview
也可以找到为 b.up('gridview')
。所以你得到:
Use indexOf
on the gridview
. You need to pass it the node
as argument, which is the HTML element representing the row. In Ext JS 6, grid rows are HTML tables, so the button's row element can be found from the button element b
as b.el.up('table')
. The gridview
can also be found as b.up('gridview')
. So you get:
var rowIndex = b.up('gridview').indexOf(b.el.up('table'));
请参阅操作: https://fiddle.sencha.com/#fiddle/snq
这篇关于如何在extjs小部件列中获取rowIndex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!