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

Keep row selection after refresh

2 Answers 381 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rema
Top achievements
Rank 1
Rema asked on 26 Sep 2012, 05:46 PM
I have an asp.net mvc grid which I am automatically refreshing every few minutes. The problem I am running into is that if the user has selected a row, the selection is lost. How can I keep that row selection?

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Pedro
Top achievements
Rank 2
answered on 08 Oct 2012, 04:53 PM
Are you using Server or Ajax databinding?
0
Xander
Top achievements
Rank 1
answered on 12 Apr 2013, 10:12 AM
Hi,
I'm trying to do the same with ajax binding and I just cannot seem to make it work. The timer is working just fine, but the row selection is lost after the refresh. I think it would be very good to get an example from Telerik as I've spent quite a bit of time searching the internet and just can't make it work. Btw, I'm using the MVC wrappers at present. What is wrong in the following code?:

var timer = $.timer(function () {
         
    // -- find currently selected row --
    var grid = $("#Grid").data("kendoGrid");
    var row = grid.select();
    var uid = row.data("uid");
         
    // -- refresh grid --
    grid.dataSource.read();
         
    // -- reselect row --
    var row2 = grid.table.find('tr[data-uid="' + uid + '"]');
    row2.addClass('k-state-selected');
     
});
timer.set({ time: 5000, autostart: true });


Thanks in advance

UPDATE: I realized this was the wrong forum so have reposted here (feel free to remove this post): http://www.kendoui.com/forums/ui/grid/maintaining-row-selection-after-an-auto-grid-refresh.aspx
thanks
Tags
Grid
Asked by
Rema
Top achievements
Rank 1
Answers by
Pedro
Top achievements
Rank 2
Xander
Top achievements
Rank 1
Share this question
or