Re-select Kendo UI Grid row after .read()

3 posts, 0 answers
  1. Conor
    Conor avatar
    7 posts
    Member since:
    Mar 2012

    Posted 28 Apr 2012 Link to this post

    Hi I am working with the Kendo UI grid and am currently able to display data from my MySQL database using JSON to transport the information.

    I am allowing the user to update the data in the database through a series of inputs, which when clicking a row on the grid are populated by an item in the grid's datasource. This is all working perfectly and very quickly. However, when I update the item I am then calling the .read() method on the datasource, and the only issue I am having is that I am not currently able to figure out how I can reselect the same row. I can loop through the datasource's views and find the view in particular that matches up to the edited item by one of its properties but I can't figure out a way to reselect it.

    var grid = $(".grid.dynamic.tbl").data("kendoGrid");;

    for (i in grid.dataSource.view()){
    if (myID == grid.dataSource.view()[i].MyID) console.log('Found correct ID at index: '+i);

    Any ideas? It is probably staring me right in the face to be honest.
  2. Alexander Valchev
    Alexander Valchev avatar
    2873 posts

    Posted 02 May 2012 Link to this post

    Hello Conor,

    The grid has a select method that accepts items (rows/cells) and will select the specified elements.
    Each record in the dataSource has an unique identified called uid that is attached as a data-uid attribute to its <tr> HTML element. I see that you already found a way to get the view in particular that matches up to the previously selected item, so you could use its uid to find the row and reselect it.
    I hope this helps.

    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!
  3. Basem
    Basem avatar
    27 posts
    Member since:
    Dec 2010

    Posted 24 May 2012 Link to this post

    I needed this too. Check out the code I posted in another thread that seems to handle sort, filter, and any other event that forces a re-read on the grid: 
Back to Top