2013-10-16 63 views
0

我是MVC控件中的新手。我在Telerik網格中使用.ToolBar(commands => commands.Insert()),它像這樣綁定到旅程模型類(@(Html.Telerik()。Grid())。 現在我的問題是我想要打電話給我的局部視圖控件時插入/編輯按鈕的點擊。Telerik網格調用局部視圖控件

謝謝

回答

0

它不是用好的做法「.ToolBar(命令=> commands.Insert())」。這將工作只是爲。很簡單的模型 你應該使用自定義命令:

.ToolBar(toolBar => toolBar.Template(@<text> 
        @Html.ActionLink("Add new ", "Action", "Controller",null, new { @class = "t-button", })</text>)) 

,插入,進行編輯 和自定義命令:

columns.Command(commands => 
        { 
         commands.Custom("Update").Text("Update") 
           .SendState(true).SendDataKeys(true) 
           .HtmlAttributes(new { f = "btnEdit" }). 
           Action("Action", "Controller").Ajax(false);      

        }).Width("15%").Title("Title"); 

如果你仍然想使用.ToolBar(commands => commands.Insert()),你應該在你的網格是這樣的:

.DataBinding(dataBinding => 
     { 
      dataBinding.Ajax() 
       .Select("Action", "Controller") 
       .Insert("Action", "Controller") 
       .Update("Action", "Controller") 
       .Delete("Action", "Controller"); 
     }) 

現在你應該擁有的共享文件夾中的文件夾命名爲EditorTempaltes並在此文件夾中部分視圖像網格模型一樣命名,但這不是很好的做法。