How to set a Row id of a grid

3 posts, 1 answers
  1. Joe
    Joe avatar
    5 posts
    Member since:
    May 2013

    Posted 25 Dec 2013 Link to this post

    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. Answer
    Joe
    Joe avatar
    5 posts
    Member since:
    May 2013

    Posted 26 Dec 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Joe
    Joe avatar
    5 posts
    Member since:
    May 2013

    Posted 26 Dec 2013 Link to this post

    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.
Back to Top