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

Retrieve detail table datakey values using client OnCommand event

1 Answer 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jonathan Puddle
Top achievements
Rank 1
Jonathan Puddle asked on 01 Sep 2010, 08:40 PM
I have a Master/Detail grid and have added some buttons with custom command names in my details grid and have attached this script to the client OnCommand event. (I have omitted code that is not relevant).

function OnCommand(sender, eventArgs)
{
      // code omitted here that used radConfirm to get user to approve the selected command
      //  ...
      // code which is executed if user confirms selected command
    var grid = sender;
    var MasterTable = grid.get_masterTableView();
    itemIndex = eventArgs.get_commandArgument();
    masterTable.fireCommand("MyCustomCommand", itemIndex);
}

The code triggers successfully but the problem is that the GridCommandEventArgs that I receive in the code-behind event (RadGrid1_ItemCommand) contains item data only for the parent row. How can I retrieve the item data for the child row that triggered the command?

I have also noticed that if I set the FireCommand method to trigger a "Delete" command, then the GridCommandEventArgs does contain the child row data, but when I change it to a custom command name, it then only sends the parent row data.

 I need to be able to at least retrieve the datakey values for the child row.


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Sep 2010, 05:53 AM
Hello Jonathan,

Try the following code snippet to get the DataKeyValue of DetailTable row.

Java Script:
<script type="text/javascript">
    function OnCommand(sender, args) {
        var index = args.get_commandArgument();
        var childIndex = index.split("_")[1]; // getting DetailTable row index
        var dataKeyValue = args.get_tableView().get_dataItems()[childIndex].getDataKeyValue("EmployeeID");//access DataKeyValue
       }
</script>

Thanks,
Princy.
Tags
Grid
Asked by
Jonathan Puddle
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or