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 => resizin开发者_运维技巧g.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)));
}
There has been a problem with editing in nested grids in the official release, which we fixed after a major refactoring of the client-side editing. You can try out an internal build or wait for the official service pack next week (27.09. - 01.10.).
I can't get model in controller Delete method: it's null
<% Html.Telerik().Grid() .Name("CustomerGrid") .Columns(columns => { columns.Bound(c => c.CustomerName).Title("Customer").Width(250); columns.Bound(c => c.CustomerAddress).Title("Address").Width(250); if (Roles.IsUserInRole("Administrator") == true) { columns.Command(comand => { comand.Edit(); comand.Delete(); }).Title("").Width(200); } columns.Bound(c => c.CustomerId).Title("CustomerId").Hidden(true); }) .ToolBar(commands => commands.Insert()) .DataKeys(keys => keys.Add(c => c.CustomerId)) .DataBinding(dataBinding => dataBinding.Ajax() .Select("CustomerListAjax", "Customer") .Insert("InsertCustomerAjax", "Customer") .Update("EditCustomerAjax", "Customer") .Delete("DeleteCustomerAjax", "Customer") ) .Sortable() .Filterable() .Editable(e => e.DisplayDeleteConfirmation(true)) .Pageable(builder => builder.PageSize(15)) .Scrollable(scrolling => scrolling.Height(500)) .PrefixUrlParameters(false) .Render(); %>
here is controller
[AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult DeleteCustomerAjax(mCustomer Customer) {
_manager.Customers.DeleteCustomer(Customer);
return View(new GridModel(_manager.Customers.GetCustomerListAjax()));
}
Who could tell me what was missed?
精彩评论