Get all detail data from hierarchy grid

7 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
    2342 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.
  4. Doug
    Doug avatar
    2 posts
    Member since:
    Jul 2012

    Posted 29 Oct Link to this post

    I need to search through all the data in the detail records in a hierarchy grid and select master rows when detail data is found. All master rows are collapsed, to many to open all. What's the best way to search through the detail data? 
  5. Tsvetina
    Admin
    Tsvetina avatar
    2342 posts

    Posted 30 Oct Link to this post

    Hi Doug,

    When the parent Grid rows are not expanded, the detail Grids do not exist, so the only way to perform the search is manually by calling a method on the server, which searches based on a value that you send from the client. Once you have the results, you can return to the client just a distinct list of parent IDs from the data records that match the search criteria.

    On the client, you can loop through the parent row ID values, locate the relevant parent rows and select them as shown in this Dojo:
    https://dojo.telerik.com/aVapEfuz

    Regards,
    Tsvetina
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  6. Doug
    Doug avatar
    2 posts
    Member since:
    Jul 2012

    Posted 30 Oct in reply to Tsvetina Link to this post

    Hi Tsvetins,

    Thank you for the reply, but actually I left out the key information on my earlier post. I'm currently pulling all the data back as a flat file and splitting it up into master and detail records for display in the grid, and in the detailInit just using a _.where the detail keys match. this is working great for displaying the info. So to search on the detail records, I populated another hidden grid with only the detail records and used it for searching the data to grab the key information. The using then looping through the original parent rows to select the parent rows on the grid.  I'm just wondering if there's a better way to do this, instead of using another hidden grid?   

    Regards

    Doug

     

     

     

  7. Tsvetina
    Admin
    Tsvetina avatar
    2342 posts

    Posted 01 Nov Link to this post

    Hello Doug,

    Wouldn't it also work if you declare only an external DataSource and not an actual Grid to do the data search on the side? You can call filter(filterExpr) for the external DataSource and use the resulting data (obtained through the view() method call) to find and select the records inside the hierarchy Grid.

    Regards,
    Tsvetina
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top