编辑父网格时,子网格在Kendo UI中得到更新

时间:2019-02-04 07:27:46

标签: kendo-ui kendo-grid kendo-asp.net-mvc

我正在使用Kendo UI绑定嵌套网格。每当我更新父网格时,其子网格也会随之更新。有什么方法可以编辑父网格并且它的子网格不受影响。我正在使用C#Asp.net

    <script>
    function onDataBound(e) {
        this.expandRow(this.tbody.find("tr.k-master-row"));
    }

    function initDetail(e) {
        var grid = $("#CustomerDetail_" + e.data.CustomerId).data("kendoGrid");
        grid.dataSource.data([e.data]);
    }
</script>

@(Html.Kendo().Grid<DetailGridSample.Models.TestData>()
            .Name("grid")
            .Editable(editable => editable
                .Mode(GridEditMode.InCell)
            )                                              
            .Columns(columns =>
            {
                columns.Bound(e => e.CustomerId).Width(120);
                columns.Bound(e => e.Customer).Width(120);
                columns.Bound(e => e.CustomerGroup).Width(120);
            })


            .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("LoadData", "Home"))
                .Model(
                        model =>
                        {
                            model.Id(t => t.CustomerId);
                        }
                 )).ClientDetailTemplateId("detailTemplate")
                   .Events(events => events.DetailInit("initDetail"))
)

<script id="detailTemplate" type="text/kendo">
    @(Html.Kendo().Grid<DetailGridSample.Models.TestData>()
                    .Name("CustomerDetail_#=CustomerId#")
                    .Editable(editable => editable
                        .Mode(GridEditMode.InCell)
                    )



                    .Editable(editable => editable
                        .Mode(GridEditMode.InCell)
                    )

                    .AutoBind(false)
                    .Columns(columns =>
                    {
                        columns.Bound(e => e.CustomerInvoice1).Width(120);
                        columns.Bound(e => e.CustomerInvoice2).Width(120);
                        columns.Bound(e => e.CustomerInvoice3).Width(120);
                    })

                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .Batch(true)
                        .Model(
                                model =>
                                {
                                    model.Id(t => t.CustomerId);
                                }
                         )).ToClientTemplate()
    )
</script>
  

在编辑父网格之前

enter image description here

  

编辑父网格后   enter image description here

0 个答案:

没有答案