1
是否可以在父网格的弹出编辑器中添加可编辑网格?这两个网格都是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