Why Are My Kendogrid "update" Parameters Always Null In The Controller?
Solution 1:
In your parameterMap: function ()
instead of using
return JSON.stringify(data);
use
return { models: kendo.stringify(data) };
here your data is serialize and attached to a name models now this name models is used as parameter name in your action
Solution 2:
You need to name the parameter in your controller inside of your parameter map function. Also it looks like you are trying to send the entire data object instead of the model. I would try this within your parameter map function:
parameterMap: function (data, operation) {
if (operation === "update" && data.models){
return {models: kendo.stringify(data.models) };
}
}
Solution 3:
- Use .Batch(true) method inside .DataSource() in view of concerned action method
Use below code inside kendo grid to create toolbar
.ToolBar(toolbar => { toolbar.Create(); toolbar.Save(); })
Edit mode of grid must be incell to add add more than one entry or in batch mode like below sample code
.Editable(ed => ed.Mode(GridEditMode.InCell).TemplateName("EditDocket").Window(w => w.Title("Docket").Name("editWindow").Width(377).Height(200).Scrollable(true)))
Use below sample code to fetch model details binds to view in controller's action method
[HttpPost] public ActionResult AppEditDocketCreate([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<UDocket> uDockets) { try { if (uDockets != null && ModelState.IsValid) { using (IVSourceEntities db = new IVSourceEntities()) { TBL_Docket tblDocket = new TBL_Docket(); foreach (var uDocket in uDockets) { tblDocket.DocketName = uDocket.DocketName; tblDocket.CreatedDate = System.DateTime.Now; db.TBL_Docket.Add(tblDocket); db.SaveChanges(); } } } } catch (DbEntityValidationException e) { } return Json(ModelState.ToDataSourceResult()); }
Only thing that needed is [Bind(Prefix = "models")]IEnumerable uDockets) as parameter to concerned action method
Post a Comment for "Why Are My Kendogrid "update" Parameters Always Null In The Controller?"