Hi
İ have Grid and Childgrid,
When i click switch on childgrid, my rest service change data and return for me new data.
İ dont want update all childgrid data, i want update i changed row. So cannot use setRowData for childgrid.
T
Hi Yahya,
Thanks for contacting Syncfusion support.
We are unable to understand your requirement clearly at our end. Kindly share the below details to validate further.
Regards,
Rajapandiyan S
Hi
Actualy it's my question.
Regards
Hi Yahya,
Thanks for your update.
We are still not clear about your requirement, kindly share the complete details requested in the previous update so that we can be able to proceed further validation.
Please provide the requested details so that we may be able to proceed further in validating the requirement.
Regards,
Joseph I.
Thank you for update.
Please just tell me that
Question: How can i updated any childgrid row.
İt s my question and clearly
Hi Yahya,
Greetings from
Syncfusion support.
Currently we are validating your query, we will provide further details on or before 10th May 2022. We appreciate your patience until then.
Regards,
Joseph I.
Hi Yahya,
Thanks for your patience.
Based on your requirement, we have prepared a sample to update the child grid row when clicking a custom button in the toolbar. You can achieve this requirement by updating the row using the `updateRow` method in the `toolbarClick` event of the EJ2 Grid.
Please refer the below code example.
|
childGrid = { dataSource: orderDatas, queryString: 'EmployeeID', allowPaging: true, editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, }, pageSettings: { pageSize: 6, pageCount: 5 }, toolbar: [ { text: 'Update Row', tooltipText: 'Update Row', id: 'updaterow', }, ], toolbarClick: (args) => { if (args.item.id == 'updaterow') { var childGrid = args.item.controlParent.element.parentElement.ej2_instances[0]; childGrid.updateRow(2, { OrderID: 10275, ShipCity: 'Graz', Freight: 136.54, ShipName: 'Ernst Handel', }); } }, columns: [ { field: 'OrderID', headerText: 'Order ID', textAlign: 'Right', width: 120, isPrimaryKey: true, }, { field: 'ShipCity', headerText: 'Ship City', width: 120 }, { field: 'Freight', headerText: 'Freight', width: 120 }, { field: 'ShipName', headerText: 'Ship Name', width: 150 }, ], };
|
Api: https://ej2.syncfusion.com/react/documentation/api/grid/#toolbar
https://ej2.syncfusion.com/react/documentation/api/grid/#toolbarclick
https://ej2.syncfusion.com/react/documentation/api/grid/#updaterow
Sample: https://stackblitz.com/edit/react-rqvzek?file=index.js
Please get back to us for further details.
Regards,
Joseph I.
Thank you so much.
Hi Yahya,
Thanks for your update.
We are glad that the provided solution resolved your query.
Please get back to us for further details.
Regards,
Joseph I.
İ want to ask something else.
how can i reach child grid via parent grid reference?
For example.
this.parentGrid.element... just like that.
because i wanna get that
updateRow(2, {
OrderID: 10275,
ShipCity: 'Graz',
Freight: 136.54,
ShipName: 'Ernst Handel',
});
Hi Yahya,
Thanks for your update.
Each childGrid is worked as a separate Grid component. We can’t get the separate childGrid instance through the parent Grid instance.
The only way is we can get all the available childGrid elements by using querySelector on the parent Grid element. Find the below code example and sample for more information.
|
btnClick(args) { var childGridsele = this.grid.element.querySelectorAll('.e-grid'); for (var i = 0; i < childGridsele.length; i++) { var childGridIns = childGridsele[i].ej2_instances[0]; // get the childGrid instances by looping all the childGrid element console.log(childGridIns); } }
|
Sample: https://stackblitz.com/edit/react-rqvzek-a2ookm?file=index.js
Regards,
Rajapandiyan S
My intent is when click on play button, i wanna update current row Please click on it to open image.
How can i do that exactly.
Hi Yahya,
Thanks for your update.
Before proceeding to the solution we would like you to provide the following details which would be helpful for further validation.
Regards,
Joseph I.
Hi Yahya,
Thanks for your update.
Query: My intent is when click on play button, i wanna update current row
Based on your requirement, you want to update a row in the child grid when
clicking a run button in that row.
When you click the run button, the click event will be triggered. By using the following code in the click event, you can dynamically update the target row in childGrid.
updateRow: https://ej2.syncfusion.com/react/documentation/api/grid/#updaterow
getRowInfo: https://ej2.syncfusion.com/react/documentation/api/grid/#getrowinfo
|
[index.js] dataSource: orderDatas, queryString: 'EmployeeID', allowPaging: true, editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, }, columns: [ { headerText: 'Edit Action', template: this.EditActionTemplate.bind(this), width: 120, }, { field: 'OrderID', headerText: 'Order ID', textAlign: 'Right', width: 120, isPrimaryKey: true, }, ], };
EditActionTemplate(args) { return <button onClick={this.UpdateBtnClick.bind(this)}>Run</button>; } UpdateBtnClick(args) { // get the current childGrid instance var childGridIns = args.target.closest('.e-grid').ej2_instances[0]; // get the row information var rowInfo = childGridIns.getRowInfo(args.target.closest('td')); // get the row Index var rowIndex = rowInfo.rowIndex; // get the row data var rowData = rowInfo.rowData; rowData.ShipCity = 'Modified'; rowData.Freight = 100; rowData.ShipName = 'Modified'; // modified row data var editedData = rowData; // update the row childGridIns.updateRow(rowIndex, editedData); }
|
Sample: https://stackblitz.com/edit/react-rqvzek-cjdahn?file=index.js
Please get
back to us if you need further assistance.
Regards,
Rajapandiyan S
If this post is helpful, please consider Accepting it as the solution so that
other members can locate it more quickly.
Thank you so much it s work for me perfecly, i appriciate.
Best regards.
Hi Yahya,
We are happy to hear that you have achieved your requirement with the solution provided.
Please get back to us if you need further assistance.
Regards,
Rajapandiyan S