This is a migrated thread and some comments may be shown as answers.

GridButtonColumn client click event

1 Answer 482 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JP
Top achievements
Rank 1
JP asked on 02 Jul 2012, 11:27 AM
Hi,

I need to check if a GridButtonColumn was clicked client-side and I also need to know for which row this was.
Getting the event was easy, I subscribed to the OnCommand client event and check if it is my button:

function OnCommand(sender, args) {
   if (args.get_commandName() == "MyCommand") {
      args.set_cancel(true);
      // need to get the current row
   }
}

But how can I access the row in which the button was clicked?

Thanks!

Edit: I just saw how to acccess the row index:
var rowIndex = args.get_commandArgument();

But how can I access the dataKeyValue of this row?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Jul 2012, 12:18 PM
Hello,

Try the following javascript.
JS:
function OnCommand(sender, args)
 {
   var value = sender.get_masterTableView().get_dataItems()[args.get_commandArgument()].getDataKeyValue("ID");
   alert(value);
}

Note:Set ClientDataKeyNames as ID.

Thanks,
Shinu.
Tags
Grid
Asked by
JP
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or