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

[Solved] Selected Row Lost After Sort

1 Answer 94 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.
Paul
Top achievements
Rank 1
Paul asked on 26 Oct 2010, 10:06 PM
I have a grid that is Server bound the first pass but then uses Ajax binding for subsquent requests.  So when the user clicks on the column header to sort by that column it calls the Ajax method in my controller class.  In that method I am using this method in my controller class:
[GridAction]
public ActionResult Grid_AjaxBinding(GridCommand command)
{
    List<MyViewModel> selectedRecords;
    CustomResult webServiceResult = GetSearchResults(this.SearchParameters, out selectedRecords);
    GridModel gridModel = new GridModel() { Data = selectedRecords, Total = selectedRecords.TotalCount };
    return View(gridModel);
}

I was wondering if anyone knew of an easy way to "reselect" the row that the user had previously selected in the Grid?  I have the row they selected stored in session but I don't see any API to select the row during the ajax binding.  I know I could hack around it in the View and change the style of the row based on the selection I have in session but was hoping to find an API i could use since this seems like a common thing to do.

Basically I am trying to not lose the row that the user selected before they did a sort in the MVC grid.  Any help or suggestions would be greatly appreciated.

Thanks,
Paul

1 Answer, 1 is accepted

Sort by
0
Paul
Top achievements
Rank 1
answered on 29 Oct 2010, 02:22 PM
Anyone have any idea on how to do this?

Thanks,
-Paul
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Paul
Top achievements
Rank 1
Share this question
or