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