This question is locked. New answers and comments are not allowed.
I've implemented batch editing in a radgrid by following this example.. The grid itself displays a list of search results. I pass the search criteria to the view using ViewData dictionary.
After the edit, I want to make sure the grid displays the exact same recordset, meaning I have to somehow get the search results stored in the view by way of hidden inputs into the [GridAction] method in the controller.
My view contains two hidden elements:
Here is the grid in my view: You can see the [GridAction] method I'm referring to is called _SaveBatchEditing
And here is my controller method. How do I get the values of those hidden elements into the controller
Can anyone shed some insight? Thanks so much!
After the edit, I want to make sure the grid displays the exact same recordset, meaning I have to somehow get the search results stored in the view by way of hidden inputs into the [GridAction] method in the controller.
My view contains two hidden elements:
<input type="hidden" id="FirstName" name="FirstName" value="@ViewData["FirstName"]"/><input type="hidden" id="LastName" name="LastName" value="@ViewData["LastName"]"/>Here is the grid in my view: You can see the [GridAction] method I'm referring to is called _SaveBatchEditing
@(Html.Telerik().Grid(Model) .Name("Grid") .DataKeys(d => d.Add<int>(a => a.Id).RouteKey("Id")) .Columns(columns => { columns.Bound<int>(c => c.Id).Width(100); columns.Bound<string>(c => c.FirstName).Width(120); columns.Bound<string>(c => c.LastName).Width(200); columns.Bound<string>(c => c.ECPostalCode).Width(100); columns.Bound<string>(c => c.Phone).Width(120); columns.Bound<string>(c => c.Street).Width(200); columns.Bound<string>(c => c.City).Width(100); columns.Bound<string>(c => c.Province).Width(75); columns.Bound<string>(c => c.PostalCode).Width(100); columns.Bound<string>(c => c.Email).Width(100); columns.Bound<bool>(c => c.OkToContact).Width(50); /*columns.Bound<string>(c => c.BirthDay).Width(130).Format("{0:d}");*/ columns.Command(commands => { commands.Edit(); commands.Delete(); }).Width(200); }) .DataBinding(dataBinding => dataBinding .Ajax() .Select("_SelectBatchEditing", "Home") .Update("_SaveBatchEditing", "Home") ) .ToolBar(commands => { commands.Insert(); commands.SubmitChanges(); }) .Sortable() .Pageable() .Scrollable(scrolling => scrolling.Height(494)).Footer(false) .Editable(editing => editing.Mode(GridEditMode.InCell)) .Editable(editing => editing.Mode(GridEditMode.InCell).DefaultDataItem(new ContactView { OkToContact = true })) .ClientEvents(events => events.OnDataBinding("Grid_onDataBinding").OnError("Grid_onError")) )And here is my controller method. How do I get the values of those hidden elements into the controller
[AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult _SaveBatchEditing([Bind(Prefix = "inserted")]IEnumerable<Contact> insertedContacts, [Bind(Prefix = "updated")]IEnumerable<Contact> updatedContacts, [Bind(Prefix = "deleted")]IEnumerable<Contact> deletedContacts) { if (insertedContacts != null) { foreach (var product in insertedContacts) { //SessionProductRepository.Insert(product); } } if (updatedContacts != null) { foreach (var product in updatedContacts) { //code to update } } if (deletedContacts != null) { foreach (var product in deletedContacts) { //SessionProductRepository.Delete(product); } } IList<ContactView> Contacts = new List<ContactView>(); // Here is where I want to redo the search using the hidden inputs
// in the view, shown above.
return View(new GridModel(Contacts)); }Can anyone shed some insight? Thanks so much!