Question about editing child grids

1 Answer 210 Views
Grid
SK
Top achievements
Rank 2
Iron
Iron
SK asked on 10 Aug 2021, 06:00 PM
I have a parent grid and when you expand a row, it opens up additional child grids with data related to that specific record. I have 2 child grids that I want to be able to edit. We currently are able to edit the parent grid and we have a button users push to take all the changes and save them to the database at the same time (using a function that finds dirty rows). However, I am unsure how to include changes from the child grids or how to even "know" that a change occurred in the child grid.
function saveChanges() {
    var items = [];
    var someGrid = $("#somegrid").data("kendoGrid");
    //Getting all Dirty Rows
    var data = someGrid.dataSource.data();
    var selectedElements = $.grep(data, function (item) {
        return item.dirty
    });
    //
    var dataText = $("#Facility").data("kendoDropDownList").text();
    var facility = dataText.split('-');
    var _facilityDesc = $.trim(facility[1]);
    var _facilityCode = $.trim(facility[0]);

    for (var j = 0; j < selectedElements.length; j++) {
        var item = selectedElements[j];

        items.push({
            'Facility': _facilityCode,
            'FacilityDescription': _facilityDesc,
            //additional columns from someGrid
 });
    }

1 Answer, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 13 Aug 2021, 07:30 AM

Hello Sabri,

I have provided an answer to the support ticket, but I am also pasting here the response, for the benefit of the community:

The Grids initialized as Detail Grids are separate components, so you can configure the CRUD functionality for them as well and have the SaveChanges button displayed on their Toolbars respectively, similar as you would configure the master Grid. In the Hierarchy Demo of the Grid the detail Grids are configured to only display data, but as mentioned above you can extend the DataSource definition, define the CRUD endpoints and implement Batch Editing for the detail Grids, for example.

To have a single button outside of the Grid and save the changes in all grids you can refer to this forum post for guidance on how to get reference to the child Grids:

Get all detail data from hierarchy grid

Once you have reference to the Grids call the saveChanges method for each Grid.

Regards,
Aleksandar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
SK
Top achievements
Rank 2
Iron
Iron
Answers by
Aleksandar
Telerik team
Share this question
or