Get all detail data from hierarchy grid

3 posts, 0 answers
  1. Lee
    Lee avatar
    2 posts
    Member since:
    Nov 2014

    Posted 14 May Link to this post

    I need to get all data for all detail grids in a hierarchy grid. All master rows in the grid are always expanded (users cannot collapse), and all mater rows will always have details. How can I get the detail grids?
  2. Tsvetina
    Admin
    Tsvetina avatar
    2234 posts

    Posted 16 May Link to this post

    Hello Lee,

    It is possible to access each visible detail Grid's data but there are some conditions that I need to list:
    1. If the detail Grids use server operations (filtering, paging), you will be able to get only the first page of data from each of them. The rest of the data is not available on the client.
    2. If the master Grid uses server operations, you will be able to access only the Grids and their data on the first master Grid page.

    If this is ok, here is what you can do:
    1. Get all detail rows in the master Grid.
    2. Find the element with k-grid class name in each detail row and get the Grid reference from it.
    3. Use the DataSource API to get the needed data items. The view() method returns only the rows from the current page of data, while the data() method returns all data items, without the filtering by parent Id. 
    function getDetailGrids(){
        var masterGrid = $("#grid").data("kendoGrid");
      var detailRows = masterGrid.element.find(".k-detail-row");
      for(var i = 0; i < detailRows.length; i++){
        var detailGrid = $(detailRows[i]).find(".k-grid").data("kendoGrid");
        console.log(detailGrid.dataSource.view());
      }
    }

    Here is a Dojo, where you can test the result:
    https://dojo.telerik.com/aqenoQuK

    Regards,
    Tsvetina
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Lee
    Lee avatar
    2 posts
    Member since:
    Nov 2014

    Posted 17 May in reply to Tsvetina Link to this post

    This works. Thanks a lot.
Back to Top