2010-09-22 23 views
0

Je rencontre un problème - la méthode du contrôleur reçoit un argument NULL (valeur du champ clé) de la vue imbriquée (détail). Qu'est-ce qui m'a manqué?Supprimer une ligne dans une grille Telerik MVC imbriquée

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

méthode Contrôleur:

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

Répondre

0

Il y a eu un problème avec l'édition dans les grilles imbriquées dans la version officielle, qui nous fixe après une modification majeure de l'édition côté client. Vous pouvez essayer un internal build ou attendre le service pack officiel la semaine prochaine (27.09 - 01.10.).

+0

Alexander, merci pour la réponse rapide – Rafael

+0

Alexander, pourriez-vous s'il vous plaît pour estimer la date finale ou s'il vous plaît fournir un lien vers – Rafael

+0

Je ne peux pas obtenir le modèle dans le contrôleur Supprimer la méthode: c'est null – Rafael

0

Je ne peux pas obtenir le modèle dans le contrôleur Supprimer méthode: il est null

<% Html.Telerik() Grille() .Nom ("CustomerGrid") .Columns (colonnes => { . columns.Bound (c => c.CustomerName) .Title ("Customer"). Largeur (250); colonnes.Bound (c => c.CustomerAddress) .Titre ("Adresse") .Width (250); if (Roles.IsUserInRole ("Administrateur") == true) { columns.Command (comand => { comand.Edit(); comand.Delete(); }). Titre (""). Largeur (200); } columns.Bound (c => c.CustomerId) .Title ("CustomerId"). Caché (true); }) .ToolBar (commandes => commands.Insert()) .DataKeys (touches => keys.Add (c => c.CustomerId)) .DataBinding (Databinding => dataBinding.Ajax() .Sélectionner ("CustomerListAjax", "client") .Insert ("InsertCustomerAjax", "client") .Update ("EditCustomerAjax", "client") .Delete ("DeleteCustomerAjax", "client") ) .Sortable() .Filterable() .Editable (e => e.DisplayDeleteConfirmation (true)) .Pageable (builder => builder.PageSize (15)) .Scrollable (scrolling => scrolling.Height (500)) .PrefixUrlPara mètres (faux) .Render(); %>

ici est contrôleur

[AcceptVerbs (HttpVerbs.Post)] [GridAction] publique ActionResult DeleteCustomerAjax (Customer mCustomer) {

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

Qui pourrait me dire quel était raté ?