We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Reference to ChildGrid's GridComponent

I am using nested Grids, I am using custom toolbar items to add advanced features, I need to know which records have been selected.

For the parent Grid I am using "REF" in the grid definition, then grid.getSelectedRecords().
I can't do the same thing for the childs. The "REF" in the definition doesn't seem to work, and neither does grid.childgrid.getSelectedRecords().

You can find the code used attached.

Attachment: Assembly__Copy_6c8fad61.7z

3 Replies

PS Pavithra Subramaniyam Syncfusion Team June 6, 2019 06:36 AM

Hi Matteo, 
Greetings from Syncfusion, 
You can achieve your requirement by getting the instance in the toolbar click event of the corresponding Grid. Pleas refer to the below code example and sample link for more information. 
export class Hierarchy extends SampleBase { 
    constructor() { 
        this.toolbarSettings = ['Add', 'Edit', 'Delete', 
        { text: 'Copy', prefixIcon: 'e-copy', id: 'cpy' }, 
        { text: 'Attach', prefixIcon: 'e-add', id: 'att' }, 
    this.sequenceToolbarSettings = [ 
        { text: 'Attach', prefixIcon: 'e-link-icon', id: 'att' }, 
        { text: 'Detach', prefixIcon: 'e-unlink-icon', id: 'det' }, 
        this.childGrid = { 
            dataSource: orderDatas, 
            queryString: 'EmployeeID', 
            toolbar: this.sequenceToolbarSettings, 
            toolbarClick: this.sequenceClickHandler,  
                                           .  .  . 
    clickHandler = (args) => { 
      if(args.item.id =='att'){ 
        let asm = this.grid.getSelectedRecords(); 
    sequenceClickHandler = (args) => { 
      if(args.item.id =='att'){ 
      var seqGrid = parentsUntil(args.originalEvent.target,"e-grid").ej2_instances[0]; 
        let seq = seqGrid.getSelectedRecords(); 
    render() { 
        return (<div className='control-pane'> 
                <div className='control-section'> 
                    <GridComponent dataSource={employeeData} childGrid={this.childGrid}  
                    ref={g => this.grid = g} 
                            .  .  . 
                        <Inject services={[DetailRow, Toolbar, Page, Sort]}/> 
render(<Hierarchy />, document.getElementById('sample')); 
Please get back to us, if you need further assistance. 
Pavithra S. 

MA Matteo June 18, 2019 09:06 AM

it works great.

Thank you!

PS Pavithra Subramaniyam Syncfusion Team June 18, 2019 11:37 PM

Hi Matteo,  

Thanks for your update. 

We are happy to hear that the provided solution is working. 

Please contact us if you need any further assistance. As always, we will be happy to assist you.  

Pavithra S. 

Live Chat Icon For mobile
Up arrow icon