Ada*_*Cox 6 command window kendo-ui kendo-grid
设置:
障碍:
如何使用新模型(来自窗口/窗体javascript)更新Grid的行(dataItem?).我无法获得目标dataItem的句柄.Select()在此处不适用,因为未选中该行.相反,自定义按钮事件打开模态网格窗口,其中包含用于更新,关闭等的字段和命令.
我可以使用原生的网格编辑,但我想要完成的是一种完全自定义弹出窗口的方法,显示可用于呈现CRUD操作的局部视图.
顺便说一句:这样做的基本原理是优化网格行中的空间,通常使用不必要的按钮进行编辑和删除,使用Kendo本机控件属性进行布局.在我的案例中,我觉得这更好地呈现在一个单独的细节视图中,就像模型网格窗口一样.
同样,不使用Select(),我无法理解如何在Window/form JavaScript中获取调用它的Grid行的句柄,以便用新模型数据更新行.
谢谢你的时间.
使用您的方法,您正在执行双重请求,因此我的建议:在编辑时打开一个通过 MVVM 绑定到行的窗口:
function edit(e) {
//get the row which belongs to clicked edit button
var item = this.dataItem($(e.currentTarget).closest("tr"));
//bind the window to the item via mvvm http://docs.telerik.com/kendo-ui/framework/mvvm/overview
kendo.bind($("#window"), item);
}
Run Code Online (Sandbox Code Playgroud)
该窗口包含一个编辑器模板(Shared/EditorTemplates/Client.cshtml):
@(Html.Kendo().Window().Name("window")
.Title("Client Details")
.Visible(false)
.Modal(true)
.Draggable(true)
.Width(400)
.Content(@<text>
@Html.Partial("EditorTemplates/Client", new Product())
</text>))
//Put in every element in the window data-bind="value:INPUT NAME"
//<input name="price" /> become <input name="price" data-bind="value: price" />
$("#window [name]").each(function () {
var name = $(this).attr("name")
$(this).attr("data-bind", "value:" + name );
});
Run Code Online (Sandbox Code Playgroud)
编辑器模板:
@model Product
@Html.TextBoxFor(m => m.Name)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5081 次 |
| 最近记录: |