This is a migrated thread and some comments may be shown as answers.

Get all detail data from hierarchy grid

6 Answers 2831 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 14 May 2018, 01:59 PM
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?

6 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 16 May 2018, 09:18 AM
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.
0
Lee
Top achievements
Rank 1
answered on 17 May 2018, 04:31 PM
This works. Thanks a lot.
0
Doug
Top achievements
Rank 1
answered on 29 Oct 2018, 03:57 PM
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? 
0
Tsvetina
Telerik team
answered on 30 Oct 2018, 01:58 PM
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.
0
Doug
Top achievements
Rank 1
answered on 30 Oct 2018, 02:31 PM

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

 

 

 

0
Tsvetina
Telerik team
answered on 01 Nov 2018, 10:06 AM
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.
Tags
Grid
Asked by
Lee
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Lee
Top achievements
Rank 1
Doug
Top achievements
Rank 1
Share this question
or