2014-09-12 62 views
0

我是新的劍道UI的ASP.NET MVC。 我想創建網格並能夠通過點擊放置在工具欄中的按鈕(創建,編輯,更新,保存,放置)來編輯選定的行,而不是在命令列表中。如何實現這一目標?這裏是我的代碼kendo ui mvc 4格編輯選定的行

@(Html.Kendo().Grid<TelerikMVC4.Models.TeacherViewModel>() 
    .Name("grid") 
    .HtmlAttributes(new{style = "font-size: 12px"}) 
    .Columns(columns => 
     { 
      columns.Bound(teacher => teacher.Name); 
      columns.Bound(teacher => teacher.Date).Format("{0:d}"); 
      columns.Command(commands => 
       { 
        commands.Edit().UpdateText("Save").Text("Edit"); 
        commands.Destroy().Text("Delete"); 
       }).Title("").Width(200); 
     }) 
    .ToolBar(toolbar => 
     { 
      toolbar.Create().Text("New"); 
     }) // The "create" command adds new data items 
    .Editable(editable => editable.Mode(GridEditMode.InLine) 
          .Window(window => 
           { 
            window.Title("Edit teacher"); 
           } 
          ) 


)// Use inline editing mode 
    .DataSource(dataSource => 
       dataSource.Ajax() 
        .Model(model => 
         { 
          model.Id(teacher => teacher.TeacherID); 
          model.Field(teacher => teacher.TeacherID).Editable(false); 
         }) 
        .Create(create => create.Action("Teachers_Create", "Teacher")) 
        .Read(read => read.Action("Teachers_Read", "Teacher")) 
        .Update(update => update.Action("Teachers_Update", "Teacher")) 
        .Destroy(destroy => destroy.Action("Teachers_Destroy", "Teacher")) 
) 
    .Pageable(pageable => pageable 
          .Refresh(true) 
          .PageSizes(false)    
          .ButtonCount(5)) 
    .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))) 

回答

0

我不知道如果我理解這個問題..你想與編輯按鈕編輯行的列之外?如果是這樣,它doenst有意義,編輯按鈕必須附加到行..

關於代碼我認爲你是用這部分代碼搞亂:

    .Editable(editable => editable.Mode(GridEditMode.InLine) 
         .Window(window => 
          { 
           window.Title("Edit teacher"); 
          } 
         ) 

您正在編輯內嵌如此爲什麼窗口標題?

 @(Html.Kendo().Grid<TelerikMVC4.Models.TeacherViewModel>() 
.Name("grid") 
.HtmlAttributes(new{style = "font-size: 12px"}) 
.Columns(columns => 
    { 
     columns.Bound(teacher => teacher.Name); 
     columns.Bound(teacher => teacher.Date).Format("{0:d}"); 
     columns.Command(commands => 
      { 
       commands.Edit().UpdateText("Save").Text("Edit"); 
       commands.Destroy().Text("Delete"); 
      }).Title("").Width(200); 
    }) 
.ToolBar(toolbar => 
    { 
     toolbar.Create().Text("New"); 
    }) // The "create" command adds new data items 
     .Editable(editable => editable.Mode(GridEditMode.InLine) 
.DataSource(dataSource => 
      dataSource.Ajax() 
       .Model(model => 
        { 
         model.Id(teacher => teacher.TeacherID); 
         model.Field(teacher => teacher.TeacherID).Editable(false); 
        }) 
       .Create(create => create.Action("Teachers_Create", "Teacher")) 
       .Read(read => read.Action("Teachers_Read", "Teacher")) 
       .Update(update => update.Action("Teachers_Update", "Teacher")) 
       .Destroy(destroy => destroy.Action("Teachers_Destroy", "Teacher")) 
) 
    .Pageable(pageable => pageable 
         .Refresh(true) 
         .PageSizes(false)    
         .ButtonCount(5)) 
    .Selectable(selectable => selectable.Mode(GridSelectionMode.Single)))