Hello
I am having a similar but very weird issue.
I am creating an editable grid in a view passing an integer model. I have configured edit, destroy and create actions. In every action I am passing back the integer model of the view to the controller. The Read, Update and Destroy actions are correctly passing this integer model. However, the Create action is not, even though it is defined in the same was as the others:
My Grid
@model int
@(Html.Kendo().Grid<MyGridModel>()
.Name("MyGridModelGrid" + Model)
.Columns(cols =>
{
cols.Bound(a => a.SomeProperty);
cols.Bound(a => a.SomeListProperty).ClientTemplate("#=iterateOver(SomeListProperty)#").Title("Properties");
cols.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(172);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.Model(m =>
{
m.Id(model=>model.Id);
m.Field(model=>model.SomeProperty);
m.Field(model=>model.SomeListProperty).DefaultValue(new List<string>());
})
.Create(update => update.Action("AddModelFor", "MyController", new { area = "MyArea" , modelId= Model}))
.Read(read => read.Action("ReadModelsFor", "MyController", new { area = "MyArea", modelId= Model }))
.Update(update => update.Action("UpdateModelFor", "MyController", new { area = "MyArea", modelId= Model }))
.Destroy(update => update.Action("RemoveModelFor", "MyController", new { area = "MyArea",modelId = Model }))
)
)
My MVC controller:
public JsonResult ReadModelsFor([DataSourceRequest] DataSourceRequest request, int modelId)
{
//correctly receiving both parameters
}
[HttpPost]
public ActionResult RemoveModelFor([DataSourceRequest]DataSourceRequest request, ServiceMapping serviceMapping, int modelId)
{
//correctly receiving the three parameters
}
[HttpPost]
public ActionResult AddModelFor([DataSourceRequest]DataSourceRequest request, ServiceMapping serviceMapping, int modelId)
{
//THIS DOES NOT RECEIVE THE MODELID!
}
[HttpPost]
public ActionResult UpdateModelFor([DataSourceRequest]DataSourceRequest request, ServiceMapping serviceMapping, int modelId)
{
//correctly receiving the three parameters
}