2010-09-22 60 views
0

我面临一个问题 - 控制器方法从嵌套(详细)视图获取NULL参数(键字段值)。 我错过了什么?删除嵌套的Telerik MVC网格中的行

<% 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(); 
%> 

控制器的方法:

[GridAction] 
public ActionResult DeleteProjectAjax(mProject project) 
{ 
    _manager.Projects.DeleteProject(project); 
    return View(new gridModel(_manager.Projects.GetProjectListAjax(project.ProjectCustomer))); 
} 

回答

0

目前已与在正式发布嵌套网格,这是我们的固定客户端编辑的主要重构后编辑的问题。您可以试用internal build或下周(27.09。 - 01.10。)等待官方服务包。

+0

亚历山大,感谢您的快速反应 – Rafael 2010-09-22 12:16:54

+0

亚历山大,请您估计最终日期或请提供链接 – Rafael 2010-10-04 14:29:13

+0

我无法在控制器中获取模型删除方法:它是空的 – Rafael 2010-10-14 15:38:05

0

我不能在控制器模型中删除方法:这是空

<%Html.Telerik()网格() 请将.Name( “CustomerGrid”) .Columns(列=> { 。 columns.Bound(c => c.CustomerName).Title(“Customer”)。Width(250); columns.Bound(c => c.CustomerAddress).Title(“Address”)。Width(250); 如果(Roles.IsUserInRole(“Administrator”)== true) {. columns.Command(comand => { comand.Edit(); comand.Delete();标题(“”)。Width(200); } columns.Bound(c => c.CustomerId).Title(“CustomerId”)。Hidden(true); }) .ToolBar(命令=> commands.Insert()) .DataKeys(密钥=> keys.Add(C => c.CustomerId)) .DataBinding(数据绑定=> dataBinding.Ajax() 。选择( “CustomerListAjax”, “客户”) .Insert( “InsertCustomerAjax”, “客户”) .Update( “EditCustomerAjax”, “客户”) .Delete( “DeleteCustomerAjax”, “客户”) ) .Sortable () .Filterable() .Editable(E => e.DisplayDeleteConfirmation(真)) .Pageable(助洗剂=> builder.PageSize(15)) .Scrollable(滚动=> scrolling.Height(500)) .PrefixUrlPara米(false) .Render(); %>

这里是控制器

的[AcceptVerbs(HttpVerbs.Post) [GridAction] 的ActionResult DeleteCustomerAjax(mCustomer客户) {

 _manager.Customers.DeleteCustomer(Customer); 
     return View(new GridModel(_manager.Customers.GetCustomerListAjax())); 
    } 

谁能告诉我什么是公众无缘?