- Home
- Forum
- React - EJ 2
- Reference to ChildGrid's GridComponent
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.
Attachment: Assembly__Copy_6c8fad61.7z
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
SIGN IN To post a reply.
3 Replies
PS
Pavithra Subramaniyam
Syncfusion Team
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.
MA
Matteo
June 18, 2019 02:06 PM UTC
it works great.
Thank you!
PS
Pavithra Subramaniyam
Syncfusion Team
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.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
MA Matteo
- Jun 5, 2019 02:13 PM UTC
- Jun 19, 2019 04:37 AM UTC