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?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Use the onWidgetAttach
http://docs.sencha.com/extjs/5.1.2/api/Ext.grid.column.Widget.html#cfg-onWidgetAttach
The function has both widget and record parameter. You can do widget.record = record, and then the button will have the record member which you can access in the click listener
Use
indexOf
on thegridview
. You need to pass it thenode
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 elementb
asb.el.up('table')
. Thegridview
can also be found asb.up('gridview')
. So you get:See in action: https://fiddle.sencha.com/#fiddle/snq
Building on Drake's answer, I'm using the
event.record
property instead. Unfortunately, it looks like you have to make the click event have a slight buffer, so it gets the proper record added to it. This works, but I'm not entirely sure if it's a proper way. Example: