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

How to set a Row id of a grid

2 Answers 719 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 2
Joe asked on 26 Dec 2013, 01:52 AM
I am looking for a simple way to set the row id when populating a grid.

For example <tr id='myunique value'><td></td></tr>

I have been looking online and have not seen a simple answer for this.

This would appear to be an easy thing so as to manipulate the grid using standard jquery 

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 26 Dec 2013, 09:00 AM
Hi Joe,

The rows in the Grid have a data-uid attribute, which is unique and is tied to the DataSource item corresponding to that row, so you could use that to easily find and get tr elements. In case you would like to add an id attribute you could do that in a couple of ways:
  • Use a rowTemplate and specify the id attribute in it 
  • Attach a handler to the Grid's dataBound event. Once it is triggered iterate over the currently displayed items using the dataSource.view method, use a jQuery selector to find the corresponding row by its uid and manually add an id attribute

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Joe
Top achievements
Rank 2
answered on 26 Dec 2013, 01:01 PM
Thank you Alexander, I did read the rowTemplate, and after re-reading it, it is what I want to accomplish overall. I was becoming lazy and looking for more simplicity in a columnTemplate, however after going over my overall plan the rowTemplate would be the more beneficial approach. Thank you for your prompt reply.
Tags
Grid
Asked by
Joe
Top achievements
Rank 2
Answers by
Alexander Popov
Telerik team
Joe
Top achievements
Rank 2
Share this question
or