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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Reference to ChildGrid's GridComponent

Thread ID:

Created:

Updated:

Platform:

Replies:

145080 Jun 5,2019 02:13 PM UTC Jun 19,2019 04:37 AM UTC React - EJ 2 3
loading
Tags: Grid
Matteo
Asked On June 5, 2019 02:13 PM UTC

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

Pavithra Subramaniyam [Syncfusion]
Replied On June 6, 2019 11:36 AM UTC

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. 
 
[index.jsx] 
export class Hierarchy extends SampleBase { 
    constructor() { 
        super(...arguments); 
        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(); 
        console.log(asm); 
        return; 
      } 
    } 
    sequenceClickHandler = (args) => { 
      if(args.item.id =='att'){ 
      var seqGrid = parentsUntil(args.originalEvent.target,"e-grid").ej2_instances[0]; 
        let seq = seqGrid.getSelectedRecords(); 
        console.log(seq); 
        return; 
      } 
        
    } 
 
    render() { 
        return (<div className='control-pane'> 
                <div className='control-section'> 
                    <GridComponent dataSource={employeeData} childGrid={this.childGrid}  
                     toolbar={this.toolbarSettings} 
                    toolbarClick={this.clickHandler} 
                    ref={g => this.grid = g} 
                    allowSorting={true}> 
                        <ColumnsDirective> 
                            .  .  . 
                        </ColumnsDirective> 
                        <Inject services={[DetailRow, Toolbar, Page, Sort]}/> 
                    </GridComponent> 
                </div> 
            </div>); 
    } 
} 
 
render(<Hierarchy />, document.getElementById('sample')); 
 
 
Please get back to us, if you need further assistance. 
 
Regards, 
Pavithra S. 


Matteo
Replied On June 18, 2019 02:06 PM UTC

it works great.

Thank you!

Pavithra Subramaniyam [Syncfusion]
Replied On June 19, 2019 04:37 AM UTC

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.  

Regards,  
Pavithra S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon