2013-02-02 3 views
-3

Comment la fenêtre contextuelle fonctionne lorsque le bouton d'édition est cliqué et comment amener les trois Combobox dans le popup. Je suis vraiment confondu avec le code ci-dessousComment fonctionne la fenêtre contextuelle dans la grille KendoUI et comment amener les contrôles dans la fenêtre contextuelle dans la grille ajax KendoUI pour MVC4

Client side Code 

    //show server errors if any 
    function error_handler(e) { 
     if (e.errors) { 
      var message = "Errors:\n\n"; 
      $.each(e.errors, function (key, value) { 
       if ('errors' in value) { 
        $.each(value.errors, function() { 
         message += this + "\n\n"; 
        }); 
       } 
      }); 
      alert(message); 
     } 
    } 


@(Html.Kendo().Grid(Model) 
    .Name("SchoolGrid") 
    .Columns(columns => 
    { 
     columns.Bound(p => p.SchoolID).Width("80px"); 
     columns.Bound(p => p.Name); 
     columns.Bound(p => p.Campus).Width("90px"); 
     columns.Bound(p => p.StateCode).Width("90px"); 
     columns.Bound(p => p.SectorCode).Width("95px"); 
     columns.Bound(p => p.MDISurveyStartDate).ClientTemplate("#= (MDISurveyStartDate == null) ? 'Not Set' : kendo.toString(MDISurveyStartDate, 'dd/MM/yyyy') #").Width("90px"); 
     columns.Bound(p => p.MDISurveyEndDate).ClientTemplate("#= (MDISurveyEndDate == null) ? 'Not Set' : kendo.toString(MDISurveyEndDate, 'dd/MM/yyyy') #").Width("90px"); 
     columns.Command(command => { command.Edit(); command.Destroy(); }).Width("190px").HtmlAttributes(new { style = "text-align:center" }); 
    }) 
    .ToolBar(tb => tb.Create().Text("Add New School")) 
    .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("EditSchool").Window(w => w.Title("Add/Edit School Details").Name("editWindow").Width(600))) 
    .DataSource(dataSource => dataSource 
     .Ajax() 
     .Model(model => model.Id(p => p.ClientID)) 
     .Events(e => e.Error("error_handler")) 
     .Read("Read_Schools", "School") 
     .Update("Update", "School") 
     .Create("Create", "School") 
     .Destroy("Destroy", "School") 
    ) 
) 


Server Side Code:- 

     [HttpPost] 
     public ActionResult Update([DataSourceRequest] DataSourceRequest request, School school) 
     { 
      try 
      { 
       if (ModelState.IsValid) 
       { 
        string errMsg = ""; 
        if (!_Service.UpdateSchool(school, out errMsg)) 
         ModelState.AddModelError("UpdateSchool", errMsg); 
       } 
      } 
      catch (Exception ex) 
      { 
       ModelState.AddModelError("UpdateSchool", ex.Message); 
      } 

      return Json(ModelState.ToDataSourceResult()); 
     } 

Répondre

0

There is code library qui montre comment manipuler le contenu de la fenêtre. Reste de l'édition est possible à travers le éditer événement de la grille (vérifier la documentation).

Questions connexes