【发布时间】:2013-10-16 05:46:25
【问题描述】:
我是 MVC 控件的新手。我在 Telerik 网格中使用 .ToolBar(commands => commands.Insert()),它绑定到这样的旅程模型类 (@(Html.Telerik().Grid())。 现在我的问题是我想在单击插入/编辑按钮时调用我的局部视图控件。
谢谢
【问题讨论】:
标签: razor telerik-grid telerik-mvc
我是 MVC 控件的新手。我在 Telerik 网格中使用 .ToolBar(commands => commands.Insert()),它绑定到这样的旅程模型类 (@(Html.Telerik().Grid())。 现在我的问题是我想在单击插入/编辑按钮时调用我的局部视图控件。
谢谢
【问题讨论】:
标签: razor telerik-grid telerik-mvc
使用“.ToolBar(commands => 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 的文件夹中的共享文件夹中拥有名为 EditorTempaltes 的文件夹,并且在此文件夹中您的局部视图命名为网格模型,但这不是一个好习惯。
【讨论】: