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

[Solved] How to determine selected row

2 Answers 115 Views
Grid for HTML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chris
Top achievements
Rank 1
Chris asked on 25 Mar 2013, 02:00 AM
I see there is a selection property on the grid that returns an object representing the current selection. How can I get the selected row data item from this?

This seems to work. Is it the intended way?

var uid = grid.selection[0].getAttribute("data-uid");
var dataItem = grid.dataSource.getByUid(uid);


Thanks
Chris

2 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 25 Mar 2013, 07:57 AM
Hi Chris,

You can also access the data item using the RadGrid API:
 
var dataItem = grid.dataItem(grid.selection[0]);

The dataItem method receives as an argument the DOM element of a grid row and returns the corresponding data item from the data source.

Regards,
Tsvetina
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Chris
Top achievements
Rank 1
answered on 25 Mar 2013, 08:07 AM
Saw that method and tried it with a index, etc but didn't think to pass in the selection object. Thanks.
Tags
Grid for HTML
Asked by
Chris
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Chris
Top achievements
Rank 1
Share this question
or