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

Grid / Hierarchy selected Id or selected Row

1 Answer 500 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fernando
Top achievements
Rank 1
Fernando asked on 08 Jun 2012, 08:24 PM
Hi there this is my first post in here, let me talk about my problem, I have a Grid with Hierarchy and I added a custom button to the child grid to show something else in a kendo window but I need and the id from the datasource of the child id.

This is my code:

$("#grid").delegate(".details-button", "click", function(e) {
           e.preventDefault();
           console.log($(this).closest("tr")); // this return the correct TR
           var dataItem = grid.data('kendoGrid').select($(this).closest("tr")); // this return null
           console.log(dataItem);
     });
});

This is based on the example of custom command.

Greetings

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 13 Jun 2012, 07:32 AM
Hello Fernando,

I am afraid your question is a bit unclear. Could you please clarify what do you mean by "I need and the id from the datasource of the child id."?

If I understood you right, you would like to retrieve the id of the record from detail grid. Then in the click function I suggest to reference the child grid and use the dataItem method. For example:
$("#grid").delegate(".details-button", "click", function(e) {
    var row = $(this).closest("tr"),
      grid = $(this).parents("[data-role=grid]").data("kendoGrid"); //gets child grid
 
    var model = grid.dataItem(row);
    console.log(model); //model contains the id
}


Greetings,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Fernando
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or