PDA

View Full Version : Add additional parameter to Grid.Command event



jchau
Aug 17, 2009, 3:39 PM
Currently, the Grid.Command event exposes the command, record, and rowIndex. Is it possible to add an additional parameter for the actual item (menu, button, etc) clicked? For example, on an item click, I want to change the grid command icon.

Here's a sample use case:
1. Each grid row shows a project (name, description, status).
2. Status is a CommandColumn with a menu. The menu items are Mark Approved, Mark Complete, etc.
3. On menu item click, I want to change the icon of the grid command to reflect the new status.


If the Command event exposes the button clicked, I can get the iconCls of the button and set its' parent's parent's icon to it.

jchau
Aug 17, 2009, 4:16 PM
It would be great if it can pass the toolbar object too =P

Vladimir
Aug 18, 2009, 6:56 AM
Hi,

I don't think that it is a good idea because after each sorting/cell editing/data rebinding the row (or grid) will be refreshed (it is mean rerendering). Toolbar which used in CommandColumn will be recreated. In this case you will loose all changes that were made outise 'prepare' function.


I recomend apply all changes in 'prepare' functions. When you need to update commands UI for particular row then call the following code



grid.view.refreshRow(record);
or

grid.view.refreshRow(grid.store.getAt(rowIndex));

jchau
Aug 18, 2009, 11:56 AM
Thanks for the suggestion. The grid refresh row worked for me.