- Home
- Forum
- ASP.NET MVC
- Returning the selected row in a grid
Returning the selected row in a grid
Hi Doug,
Thanks for using Syncfusion products.
We can achieve your requirement with the following steps. Please refer them.
1. Place a hidden type input element in the form as follows.
|
@using (Html.BeginForm()) { <input type="hidden" name="GridData" id="GridData" value=""/> . . . . <input type="submit" value="Submit" />
} |
2. Retrieve the selected row of grid using RowSelected event and update it in the hidden element.
|
@using (Html.BeginForm()) { <input type="hidden" id="GridData" value=""/>
@(Html.EJ().Grid<object>("ExportGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) .AllowPaging() . . . . . . .ClientSideEvents(evt => evt.RowSelected("onRowSelected"))) <input type="submit" value="Submit" />
} [JS] function onRowSelected(args) {
//Retrieve the selected recrods of the grid var result = this.getSelectedRecords();
//stringify and place the grid`s selected record as value of hidden element $("#GridData").val(JSON.stringify(result)); } |
3. Now on form submit, we can retrieve the selected row data at the controller side using the name “GridData”.
Please let us know if you need further assistance.
Regards,
Madhu Sudhanan. P
- 3 Replies
- 4 Participants
-
DM Doug Matulis
- Mar 6, 2015 11:37 PM UTC
- Jun 2, 2016 06:59 AM UTC