ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
return to selected row after my own edit form opened
Title:
B
I
{code}
?
1. user is on a view that contains grid. User selects a row on page n. It shows as highlighted. 2. use clicks my button that opens my own edit view(not the built in Edit button on the row). Primary key is passed into parms of the controller method GET. I get the data and populate model, and then present my Edit view. -- question: how do I pass the primary key of selected row to my controller GET action 3. User makes some changes on my view, presses Save. I update database. I return to view that has grid. 4. Grid refreshes but I want to position grid back to the row user started with on page n and select it again. question: how do I position the grid selection back to the selected row the user started with and show it highlighted again? Thank you--
Save Changes
Cancel
tdev
asked at 06 Mar 2017
Answers
B
I
{code}
?
to pass in the primary key to the GET action you need to generate a link or a button with the id parameter, you can use `Column.ClientFormat` for that: new Column { ... ClientFormat = "<button type='button' data-id=".Id" onclick='myedit()' >edit</button>" in this case myedit js func will be called with the id as parameter, or new Column { ... ClientFormat = @Html.ActionLink("edit","Edit", new { id = ".Id"}) http://demo.aspnetawesome.com/GridDemo/CustomFormat you can select the row if you know the id $('#gridid .awe-row[data-k=" + theid + "]').addClass('awe-selected'); the real challenge is to have the row on the first page of the grid, or maybe have the needed page active, plus the same sorting rules, you can also use [http://aspnetawesome.com/learn/mvc/Grid#Persistence Persistence] this will save the page and sorting rules
Save Changes
Cancel
Omu
answered at 06 Mar 2017
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK