Hierarchy grid. Show row as expandable only if it has data for child grid

Hello,

is there a possibility to show expandable grid row only if its child component is not empty?

I am getting data from WebAPI and I am getting property like HasChildren. It shows if a row has child grid or not. If a row do not have childGrid, I do not want to show an arrow and allow to expand that row. Now if we set childGrid property it is set to all row event there are any data for child grid or not.

For example I have data to show like this:
1
--2
--3
--4
----4.1
----4.2
--5
----5.1

I want to show arrow only in 1, 4 and 5, because these rows have child grids.

6 Replies

RS Renjith Singh Rajendran Syncfusion Team July 2, 2018 11:36 AM UTC

Hi AC, 

Thanks for contacting Syncfusion support. 

We have achieved your requirement by using rowDataBound event in Grid. This event will be triggered each time a request is made to access row information, element, or data. This will be triggered before the row element is appended to the Grid element. Please refer to the following code example and Help documentation,  

[Grid] 
 
<ejs-grid #grid [dataSource]='parentData' [childGrid]='childGrid' (rowDataBound)='rowDataBound($event)' > 
    ... 
</ejs-grid> 
 
[ts file] 
 
import { fdata } from './datasource.spec'; 
... 
export class FetchDataComponent { 
    ... 
    ngOnInit(): void { 
        ... 
       this.parentData = new DataManager({ 
            url: '/api/Orders', 
            adaptor: new WebApiAdaptor, 
            offline: true 
        }); 
       this.childGrid = { 
            dataSource: fdata, 
            queryString: 'ID', 
            ... 
       }; 
    } 
    rowDataBound(args: any) { 
        var filter = args.data.EmployeeID; 
       var dataQuery = new DataManager(fdata).executeLocal(new Query().where("ID", "equal", parseInt(filter), true)); 
        if (dataQuery.length == 0) { 
            //here hide which parent row has no child records 
            args.row.querySelector('td').innerHTML = " "; 
            args.row.querySelector('td').className = "e-customizedExpandcell"; 
        } 
    } 
} 
 
[Styles] 
 
<style> 
    .e-row[aria-selected="true"] .e-customizedExpandcell { 
        background-color: #e0e0e0; 
    } 
 
    .e-customizedExpandcell { 
    } 
 
    .e-grid.e-gridhover tr[role='row']:hover { 
        background-color: #eee; 
    } 
</style> 
 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran.  



TV Toni Veintimilla February 5, 2019 07:13 PM UTC

Hi,

regarding this... what about the excel export filtering the empty child rows? Its is exporting the child headers for every hierarchy even if it has empty data.

Bests,


MS Madhu Sudhanan P Syncfusion Team February 6, 2019 01:08 PM UTC

Hi Toni, 

Thanks for your update. 
We have validated your query and we confirmed “Need to exclude empty child grid from exported document ” as a defect and logged a report for the same and we will include the defect fix in any of our upcoming release.  
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link <feedback link>. 
Regards, 
Madhu Sudhanan P 



TS Thavasianand Sankaranarayanan Syncfusion Team April 25, 2019 05:41 AM UTC

Hi AC, 

Thanks for your patience. 
 
We are glad to announce that our Essential Studio 2019 Volume 1 Release v17-1-0-38 is rolled out and is available for download under the following link.  
 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.  

Regards, 
Thavasianand S. 



IC Isaias Chalvatzoglou February 24, 2021 04:58 PM UTC

Hello.

Can you give me please an example how i can "exclude empty child grid from exported document"?

I also noticed that when I export about 1000 rows the exporting is very slow (i stacks and i don't know how much time needs to do the exporting)


BS Balaji Sekar Syncfusion Team February 25, 2021 12:53 PM UTC

Hi Isaias, 

Before proceeding your query please share the below details to us that will help to validate further. 
  1. Ensure the rendered Grid columns count.
  2. If you using excelQueryCellInfo, pdfQueryCellInfo events in your sample, please share code definition.
  3. Please share video demonstration of the problem.
  4. If possible share the replicated sample.
 
Regards, 
Balaji Sekar 


Loader.
Up arrow icon