This project is read-only.

Maintaining selection after POST

Mar 12, 2014 at 12:46 PM
I've successfully implemented code to return to the correct grid page after post but I would also like to maintain the selected item.

My idea was to put something in the OnRowSelect that would store the currently selected row number into a hidden field.

After post, there would be script in the document.ready() which would select the correct row by calling click() for the previously selected row #.

i.e. $(".grid-row(eq("+n+")").click();

Where n is the row number.

Has anyone done anything like this, the bit I'm currently struggling with is getting the row number for the currently selected row in the onRowSelect event as e doesn't seem to have a row number property/
Mar 12, 2014 at 5:41 PM
Edited Mar 12, 2014 at 5:50 PM
Managed to solve this with the following:
int i=0;
@Html.Grid(Model).Named("myGrid").Columns(columns =>

       columns.Add(true).Titled("RowNo").RenderValueAs(x=>i++.ToString()).Name = "RowNo";

``` I can now identify which row has been selected with: e.row.RowNo

++ should by two plus signs
Marked as answer by mikelahey on 3/12/2014 at 9:51 AM