我已經有了一個MVC 3項目,我使用Kendo UI Grid非常多。是否有可能爲同一個Kendo UI Grid使用不同的編輯器模板?
的典型視圖看起來是這樣的:
@using Kendo.Mvc.UI
@model List<ActionViewModel>
@(Html.Kendo().Grid<ActionViewModel>()
.Name("#grid")
.Columns(columns =>
{
columns.Bound(p => p.Name);
columns.Command(command => { command.Edit(); command.Destroy(); });
})
.ToolBar(toolbar => toolbar.Create().Text(Resources.Grid.Create))
.Editable(editable => editable.Mode(GridEditMode.PopUp)))
.Sortable()
.Scrollable()
.Filterable(f=>f.Extra(true))
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.Id))
.Create(update => update.Action("Create", "Action"))
.Read(read => read.Action("Read", "Action"))
.Update(update => update.Action("Update", "Action"))
.Destroy(update => update.Action("Delete", "Action"))
))
我經常要定義自定義編輯模板,我的ViewModels,這些在劍道UI的編輯彈出使用。
在Kendo UI Grid中,可以創建,更新和刪除元素。編輯和創建的彈出窗口默認使用相同的編輯器模板。有沒有一種簡單的方法來編輯和刪除兩個單獨的編輯器模板?
謝謝!不是我希望的答案,但至少我得到了一個答案:) – Marius
如果你再次查看論壇帖子,已經發布了兩個更簡單的(再次使用JavaScript,對不起)答案,利用關於內部工作的知識網格小部件。它涉及找到包含所選行的ID的變量,該行通過事件鏈傳遞。如果它爲空或空白,那麼它是一個插入(添加),如果不是,那麼它是一個更新(編輯)。 http://www.kendoui.com/forums/ui/grid/kendo-grid---how-to-have-different-custom-editor-for-update-and-create.aspx#2325121 – Adrian
這裏是正確的解決方案:http://stackoverflow.com/questions/14321396/kendo-ui-grid-different-templates-for-edit-and-create – ataravati