6

詳細編集のために一度に 1 行だけ展開できるようにしたい剣道グリッドがあります。これを行う最も簡単な方法は何ですか?

@(Html.Kendo().Grid<MyModel>()
   .Name("MyGrid")
   .ClientDetailTemplateId("MyTemplate")
   .Columns(columns =>
   {
       columns.Bound(b => b.Code);
       columns.Bound(b => b.Name);
       columns.Bound(b => b.Description);
       ...
       columns.Command(cmd => { cmd.Edit(); cmd.Destroy(); });
   })
   .ToolBar(toolbar => toolbar.Create())
   .Editable(editable => editable.Mode(GridEditMode.InLine))
   .DataSource(dataSource => dataSource
      .Ajax()
      .Model(model => model.Id(a => a.Id))
      .Create(create => create.Action("Create", "SysMaint", new { id = Model.ProjectId }))
      .Read(read => read.Action("Read", "SysMaint", new { projectId = Model.ProjectId }))
      .Update(update => update.Action("Update", "SysMaint"))
      .Destroy(destroy => destroy.Action("Destroy", "SysMaint"))
   )
)

<script id="MyTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().TabStrip()
       .Name("TabStrip_#=Id#")
       .SelectedIndex(0)
       .Items(items =>
           {
               items.Add().Text("A").LoadContentFrom("MyPartialA", "SysMaint", new { id = "#=Id#" });
               items.Add().Text("B").LoadContentFrom("MyPartialB", "SysMaint", new { id = "#=Id#" });
           })
       .ToClientTemplate()
    )
</script>
4

4 に答える 4

10

結局のところ、これは本当に簡単です。これらの数行を追加するだけです。

      ...
      .Update(update => update.Action("Update", "SysMaint"))
      .Destroy(destroy => destroy.Action("Destroy", "SysMaint"))
   )
   .Events(events => events.DetailExpand("detailExpand"))
)

<script type="text/javascript">
    var expandedRow;
    function detailExpand(e) {
        // Only one open at a time
        if (expandedRow != null && expandedRow[0] != e.masterRow[0]) {
            var grid = $('#MyGrid').data('kendoGrid');
            grid.collapseRow(expandedRow);
        }
        expandedRow = e.masterRow;
    }
</script>

これが誰かに役立つことを願っています。

于 2013-02-13T03:01:53.740 に答える
5

古い詳細行を削除しないことを除いて、これは機能します。NEW とマークされたビットを追加して、以前に開いた各詳細行を削除します。

if (expandedRow != null && expandedRow != e.masterRow[0]) {
    var grid = $('#RequestsGrid').data('kendoGrid');
    grid.collapseRow(expandedRow);
    expandedRow[0].nextElementSibling.remove(); //NEW
}
expandedRow = e.masterRow;
于 2013-09-12T19:31:07.027 に答える