I face a problem - the controller method gets a NULL argument (key field value) from the nested (detail) view. What did I miss?
<% Html.Telerik().Grid<mCustomer>()
.Name("CustomerGrid")
.Columns(columns =>
{
columns.Bound(c => c.CustomerId).Title("CustomerId").Visible(false);
columns.Bound(c => c.CustomerName).Title("Customer");
columns.Bound(c => c.CustomerAddress).Title("Address");
columns.Command(comand =>
{
comand.Edit();
comand.Delete();
}).Title("Command");
})
.ToolBar(commands => commands.Insert())
.DataKeys(keys => keys.Add(c => c.CustomerId))
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("CustomerListAjax", "Customer")
.Insert("InsertCustomer", "Customer")
.Update("EditCustomer", "Customer")
.Delete("DeleteCustomer", "Customer")
)
.ClientEvents(events => events.OnRowDataBound("customer_onRowDataBound"))
.DetailView(detail => detail.ClientTemplate(
Html.Telerik().Grid<mProject>("<#= CustomerId #>")
.Name("Projects_<#= CustomerId #>")
.DataKeys(k => k.Add(p => p.ProjectId))
.Columns(columns =>
{
//columns.Bound(p => p.ProjectId).Visible(false);
columns.Bound(p => p.ProjectName).Visible(true).Title("Project").Width(180);
columns.Bound(p => p.ProjectCustomer).Width(340).Visible(false);
columns.Bound(p => p.IsForcast).Visible(true).Title("Is Forecast").Width(150).ClientTemplate("<input type='checkbox' name='chkForecast' disabled='disabled' <#= IsForcast? \"checked='checked'\" : \"\" #> /> ").HtmlAttributes(new { style = "text-align:center" });
columns.Bound(p => p.RateMode).Visible(true).Title("Rate").Width(80);
columns.Bound(p => p.IsVacationPaid).Visible(true).Title("Vacation Paid").Width(100).Width(150).ClientTemplate("<input type='checkbox' name='chkIsVacationPaid' disabled='disabled' <#= IsVacationPaid? \"checked='checked'\" : \"\" #> />").HtmlAttributes(new { style = "text-align:center" });
columns.Bound(p => p.IsHolidayPaid).Visible(true).Title("Holiday Paid").Width(100).Width(150).ClientTemplate("<input type='checkbox' name='chkHolidayPaid' disabled='disabled' <#= IsHolidayPaid? \"checked='checked'\" : \"\" #> />").HtmlAttributes(new { style = "text-align:center" });
columns.Bound(p => p.IsSickDaysPaid).Visible(true).Title("Sickness Paid").Width(100).Width(150).ClientTemplate("<input type='checkbox' name='chkSickDaysPaid' disabled='disabled' <#= IsSickDaysPaid? \"checked='checked'\" : \"\" #> />").HtmlAttributes(new { style = "text-align:center" });
columns.Bound(p => p.StartDate).Title("Start Date").Width(100).Width(130).Format("{0:d}");
columns.Bound(p => p.Probability).Title("Probability").Format("{0:N3}").Width(100);
//columns.Bound(p => p.AccountManager).Title("Owner").Width(100).Width(150);
columns.Command(comand =>
{
comand.Edit();
comand.Delete();
}).Title("Command").Width(200);
}
)
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("ProjectListAjax", "Customer", new { CustomerId = "<#= CustomerId #>" })
.Delete("DeleteProjectAjax", "Customer")
.Insert("InsertProjectAjax", "Customer", new { ProjectCustomer = "<#= CustomerId #>" })
.Update("EditProject", "Customer")
)
//.ClientEvents(e=>e.OnDataBound("project_OnDataBound").OnEdit("project_OnEdit"))
.ToolBar(commands => commands.Insert())
.RowAction(row =>
{
})
//.Selectable(s=>s.Enabled(true))
.Filterable()
.Pageable()
.Sortable()
.Resizable(resizing => resizing.Columns(true))
.Editable(e => e.DisplayDeleteConfirmation(true).Enabled(true))
.ToHtmlString()
))
.Sortable()
.Selectable()
.Filterable()
.Resizable(resizing => resizing.Columns(true))
.Editable(e => e.DisplayDeleteConfirmation(true))
.Pageable(builder => builder.PageSize(10))
.Groupable()
.Scrollable(scrolling => scrolling.Height(500))
.PrefixUrlParameters(false)
.Render();
%>
Controller method:
[GridAction]
public ActionResult DeleteProjectAjax(mProject project)
{
_manager.Projects.DeleteProject(project);
return View(new gridModel(_manager.Projects.GetProjectListAjax(project.ProjectCustomer)));
}