PDA

View Full Version : How to determine which cell in a GridPanel has been clicked.



sl5337
4 Sep 2011, 8:29 AM
In ExtJS 3.x I used the cellclick event which provided the row index and column index. I don't see an equivalent event for the GridPanel in ExtJS 4.x. Using Firebug I have inspected the arguments passed in the itemclick event but I don't see any information that indicates which column was clicked unless I'm missing something obvious, which is entirely possible. Thanks in advance for your help.

ero
4 Sep 2011, 9:31 AM
Have a look at the following thread:

http://www.sencha.com/forum/showthread.php?135042-How-to-get-column-of-cell-context-menu-in-ExtJS4&highlight=listener+column

It has helped me for a similar challenge with treepanel.

skirtle
4 Sep 2011, 9:58 AM
See also:

http://www.sencha.com/forum/showthread.php?144666

sl5337
4 Sep 2011, 10:25 AM
Thanks for the replies. I had seen those other threads but was concerned about using an "undocumented" feature. It would be reassuring to me if someone from the Ext team could confirm that the cellclick event is still supported and is the correct way of referencing a cell in a grid row when the user clicks on it.

skirtle
4 Sep 2011, 10:53 AM
Ext 4 still has a lot of documentation oversights. If you'd like to see those events documented then there's a sticky thread in the bugs forum especially for reporting documentation issues.

Given the negligible amount of effort involved I don't see any drawbacks to using them.

ero
5 Sep 2011, 7:21 AM
I've just spent a bit of time working on my app with the solution that I proposed and the one from skirtle and I should say that the one from skirtle (using cellclick) seems to work better for me.

My app has a treepanel with grouped headers and when I used itemclick and view.getPositionByEvent() I ran into a lot of issues. Basically it come down to the fact that view.panel.column showed only 6 columns which is true if you count each grouped column as 1. However, I actually have 9 columns and I would end up trying to get a column that was out of range.

May not have a lot to do with your situation, but I thought I would share.

Also, I share your concern about using undocumented features. Maybe it will get documented in 4.1: http://www.sencha.com/blog/what-to-expect-in-ext-js-4-1/

skirtle
5 Sep 2011, 4:04 PM
Also, I share your concern about using undocumented features. Maybe it will get documented in 4.1: http://www.sencha.com/blog/what-to-expect-in-ext-js-4-1/

If someone reports it to the documentation bugs thread it will probably get documented. If it doesn't then it's still your best chance of getting someone to confirm why.