I'm using a grid with editable mode set to pop up. On the actions I have included a route value to be sent to the controller. This route value gets sent on each of the CRUD calls except for the create.
Below is my Grid code with the route values for each of the actions. I really only need this value passed through for the Create and Read actions.
@(Html.Kendo().Grid(Model).Name("ApprovalProcessSteps").Columns(c =>
{
c.Bound(e => e.ProcessStep);
c.Bound(e => e.ProcessStepType);
c.Bound(e => e.AndOr);
c.Bound(e => e.GroupParentStep);
c.Bound(e => e.UserId);
c.Bound(e => e.RejectToStep);
c.Bound(e => e.ReminderFrequency);
c.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(200);
})
.ToolBar(toolbar => toolbar.Create().Text("Create New Step"))
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ApprovalProcessStepPopUp"))
.Pageable(pager => pager.AlwaysVisible(false).PageSizes(new List<
object
> {5, 10, 20, 100}))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Model(model => model.Id(p => p.Id))
.Create(update => update.Action("EditingPopup_Create", "ApprovalProcessSteps", new { approvalProcessId = ViewBag.approvalProcessId }))
.Read(read => read.Action("EditingPopup_Read", "ApprovalProcessSteps", new { approvalProcessId = ViewBag.approvalProcessId }))
.Update(update => update.Action("EditingPopup_Update", "ApprovalProcessSteps", new { approvalProcessId = ViewBag.approvalProcessId }))
.Destroy(update => update.Action("EditingPopup_Destroy", "ApprovalProcessSteps", new { approvalProcessId = ViewBag.approvalProcessId })))
)
Below is my controller code. The route value gets pass to all but my Create call. Can any point me in the right direction on what I might be doing wrong.
public
ActionResult EditingPopup_Read([DataSourceRequest] DataSourceRequest request,
int
approvalProcessId)
{
ViewBag.approvalProcessId = approvalProcessId;
return
Json(
this
.ReadInline(approvalProcessId).ToDataSourceResult(request));
}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult EditingPopup_Create([DataSourceRequest] DataSourceRequest request, ApprovalProcessStep approvalProcessStep,
int
approvalProcessId)
{
if
(approvalProcessStep !=
null
&& ModelState.IsValid)
{
this
.CreateInline(approvalProcessStep, approvalProcessId);
}
return
Json(
new
[] {approvalProcessStep}.ToDataSourceResult(request, ModelState));
}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, ApprovalProcessStep approvalProcessStep)
{
if
(approvalProcessStep !=
null
&& ModelState.IsValid)
{
this
.UpdateInline(approvalProcessStep);
}
return
Json(
new
[] {approvalProcessStep}.ToDataSourceResult(request, ModelState));
}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult EditingPopup_Destroy([DataSourceRequest] DataSourceRequest request, ApprovalProcessStep approvalProcessStep)
{
if
(approvalProcessStep !=
null
)
{
this
.DestroyInline(approvalProcessStep);
}
return
Json(
new
[] {approvalProcessStep}.ToDataSourceResult(request, ModelState));
}