是否可以在父网格的弹出编辑器中添加可编辑网格?两个网格都是 Ajax 绑定。
父网格视图:
@(Html.Kendo().Grid<MyProject.Business.Models.ParentDTO>().Name("ParentGrid")
.Columns(cols => cols.Command(o => o.Edit() ).Title(" "))
.Editable(editor => editor.Mode(GridEditMode.PopUp))
.Events(events=>events.Edit("onEditOfParentGrid"))
.DataSource(datasource => datasource
.Ajax()
.Model(model => model.Id(o => o.id))
.Read(read => read.Action("GetAll", "ParentAjax"))
.Update(update => update.Action("Update", "ParentAjax"))
.Create(create => create.Action("Create", "ParentAjax"))
.Destroy(destroy => destroy.Action("Destroy", "ParentAjax"))
)
)
<script type="text/javascript">
function onEditOfParentGrid(e) {
$('#ChildGrid').data().kendoGrid.dataSource.read({ id: e.model.id })
}
</script>
子网格视图(父母的默认 EditorTemplate):
@model MyProject.Business.Models.ParentDTO
@(Html.Kendo().Grid<MyProject.Business.Models.ChildDTO>().Name("ChildGrid")
.AutoBind(false)
.Editable(edit=>edit.Mode(GridEditMode.InCell))
.DataSource(datasource => datasource
.Ajax()
.Model(model =>model.Id(o => o.id))
.Read(read => read.Action("GetByParentId", "ChildAjax"))
.Update(update => update.Action("Update", "ChildAjax"))
.Create(create => create.Action("Create", "ChildAjax"))
.Destroy(destroy => destroy.Action("Destroy", "ChildAjax"))))
这样做会通过内联显示弹出编辑器并编写一些javascript(作为文本)来搞砸弹出编辑器。子网格也会丢失数据。如果子网格没有编辑器(又名只读),一切正常,数据显示。
控制台中有一个 jQuery 错误,但它(至少对我而言)并没有说明什么
Uncaught SyntaxError: Unexpected token ILLEGAL jquery-1.8.2.js:564
(anonymous function) jquery-1.8.2.js:564
jQuery.extend.globalEval jquery-1.8.2.js:565
(anonymous function) jquery-1.8.2.js:6006
jQuery.extend.each jquery-1.8.2.js:611
jQuery.fn.extend.domManip jquery-1.8.2.js:5991
jQuery.fn.extend.append jquery-1.8.2.js:5764
jQuery.fn.(anonymous function) jquery-1.8.2.js:6186
h.extend._createPopupEditor kendo.all.min.js:8
h.extend.editRow kendo.all.min.js:8
(anonymous function) kendo.all.min.js:8
jQuery.event.dispatch jquery-1.8.2.js:3063
elemData.handle.eventHandle jquery-1.8.2.js:2681