PDA

View Full Version : [CLOSED] ImageCommandColumn command handler



jchau
Jan 11, 2013, 4:13 AM
Is it possible to get a reference to the actual imagecommand object during the command listener? Currently, the listener has the following parameters




item,command,record,recordIndex,cellIndex

item is actually the imagecommandcolumn, and not the actual imagecommand. command is just text. During the prepareCommand handler, I add some custom properties to the command object. I would like to retrieve those during the command event.

Baidaly
Jan 11, 2013, 5:00 AM
Hello!

Try to use in the handler following code to get command:



item.commands.filter(function(c) { if (c.command == command) return c; })[0]

jchau
Jan 11, 2013, 2:05 PM
Hello!

Try to use in the handler following code to get command:



item.commands.filter(function(c) { if (c.command == command) return c; })[0]


item.commands only contain the initial config and not any modifications i made during the prepareCommands handler.

Vladimir
Jan 11, 2013, 2:16 PM
Hi,

image command object doesn't saved anywhere, it is just passed to template during rendering
I suggest to save required information inside record object

jchau
Jan 11, 2013, 3:38 PM
Hi,

image command object doesn't saved anywhere, it is just passed to template during rendering
I suggest to save required information inside record object

So if I have multiple commands, I need to store all the commands on the record object and then on command event, loop through those, and match by command text to find the command?

Vladimir
Jan 11, 2013, 3:43 PM
Well, loop is not required, you can save command info in prepareCommand


record.commands = record.commands || {};
record.commands[commandName] = {.....};


In Command listener


var obj = record.commands[commandName] || {};

jchau
Jan 11, 2013, 6:51 PM
I will give that a try.

What about the event argument? Anyway to get "e" from the command event? I am manually creating a menu and want to show it next to the imagecommand (trying to hack my own version of command with a dropdown menu without using the slower CommandColumn)

jchau
Jan 11, 2013, 7:44 PM
Looks like I can just do Ext.EventObject to get the current "e" event object. Thanks!