Hierarchy Grid grid with multiple child Same level reactjs

Hello, In reactjs  is it possible to have multiple child on the same level in the Hierarchy  grid component ?

If yes, can i have an example ? thanks

1 Reply 1 reply marked as answer

SM Shalini Maragathavel Syncfusion Team February 10, 2021 11:11 AM UTC

Hi Federic, 

Thanks for contacting Syncfusion support.

Based on your query we suspect that you want to render multiple child Grids in the same hierarchy level. You can achieve your requirement using “Detail Template” feature of Grid as demonstrated in the below code snippet, 
 
 
export class Localbinding extends SampleBase { 
     constructor() { 
        this.template = this.gridTemplate; 
    } 
        detailDataBound(e) { 
          var firstchilddata = new DataManager(hierarchyOrderdata).executeLocal(new Query().where("EmployeeID", "equal", e.data.EmployeeID, false)); 
     var secondchilddata = new DataManager(employeeData).executeLocal(new Query().where("EmployeeID", "equal", e.data.EmployeeID, false)); 
        var detail1 = new Grid({ 
           . . . 
        }); 
        detail1.appendTo(e.detailElement.querySelector('.custom-grid1')); 
        var detail1 = new Grid({ 
            . . . 
        }); 
        detail1.appendTo(e.detailElement.querySelector('.custom-grid2')); 
    } 
    gridTemplate(props) { 
        
        return  
            <div><p><b>ChildGrid1</b></p> 
                <div className='custom-grid1'></div> 
                </div> 
                  <div><p><b>ChildGrid2</b></p> 
                <div className='custom-grid2'></div> 
                </div> 
); 
    } 
    render() { 
        return (<GridComponent dataSource={employeeData} detailTemplate={this.template.bind(this)}  detailDataBound={this.detailDataBound.bind(this)} width='auto'> 
                        <ColumnsDirective> 
                        . . . 
                        </ColumnsDirective> 
                        <Inject services={[DetailRow]}/> 
                    </GridComponent> 
              ); 
     
    } 
} 
 


Please find the below sample for your reference. 

Sample : https://stackblitz.com/edit/react-baeend-ny7k1x?file=index.js

API Link: https://ej2.syncfusion.com/react/documentation/api/grid/#detaildatabound
                https://ej2.syncfusion.com/react/documentation/api/grid/#detailtemplate
               https://ej2.syncfusion.com/react/documentation/data/querying/#querying
               
                

Please get back to us if you need further assistance.
 

Regards, 
Shalini M. 


Marked as answer
Loader.
Up arrow icon