私はあなたが(MVC editor template内側)ポップアップエディタ内の別のグリッドに子どもを編集する必要がありますね。子グリッドは、親ID(modelA_ID
)を入力パラメーターとする独自のコントローラー/アクションにバインドする必要があります。
@(Html.Kendo().Grid<ModelA>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.Name);
columns.Command(command =>
{
command.Edit();
command.Destroy();
});
})
.ToolBar(tools => tools.Create())
.Editable(editable => editable
.Mode(Kendo.Mvc.UI.GridEditMode.PopUp)
.TemplateName("MyTemplate"))
.Pageable().Sortable().Filterable()
.DataSource(source => source.Ajax()
.Model(model => model.Id(e => e.ID))
.Read(read => read.Action("Read_ModelA", "MyController"))
.Update(update => update.Action("Update_ModelA", "MyController"))
.Create(create => create.Action("Create_ModelA", "MyController"))
.Destroy(destroy => destroy.Action("Destroy_ModelA", "MyController"))))
、あなたが持っているかもしれないエディタのテンプレート(MyTemplate.cshtml
)中:
メイングリッドは次のように見えるかもしれ
@model ModelA
@Html.HiddenFor(m => m.ModelA_ID)
@(Html.Kendo().Grid<ModelB>()
.Name("childGrid")
.Columns(columns =>
{
columns.Bound(o => o.Role);
columns.Command(command =>
{
command.Edit();
command.Destroy();
});
})
.ToolBar(tools => tools.Create())
.Editable(editable => editable
.Mode(Kendo.Mvc.UI.GridEditMode.InLine))
.Pageable().Sortable().Filterable()
.DataSource(source => source.Ajax()
.Model(model => model.Id(e => e.ID))
.Read(read => read.Action("Read_ModelB", "MyController").Data("getCurrentParentId"))
.Create(create => create.Action("Create_ModelB", "MyController").Data("getCurrentParentId"))
.Update(update => update.Action("Update_ModelB", "MyController"))
.Destroy(destroy => destroy.Action("Destroy_ModelB", "MyController")))
.ToClientTemplate()
)
とJavaScript関数getCurrentParentId
は、次のようになります。
function getCurrentParentId() {
return {
modelA_ID: $('#ModelA_ID').val()
}
}
グリッドから行を編集するか、他のデータがありますかカスタムウィンドウで編集したいですか? – mrmashal
申し訳ありませんが、私の質問にモデルを追加します。ありがとうございます。 –
モデルを追加する必要はありません。あなたの質問がグリッド編集に関するものかどうか分かりませんでしたか? – mrmashal