- Home
- Forum
- Angular - EJ 2
- Error when editing with template
Error when editing with template
Hello, I am encountering an error when trying to edit a cell with a custom edit template and a dropdown list in it.
I was able to reproduce the issue here: https://stackblitz.com/edit/stackblitz-starters-pdzpwh?file=src%2Fmain.ts
Hi Niels,
Greetings from Syncfusion support
After reviewing your shared stackblitz sample, we could see that in editTemplate you are defined Form element and within the form you have rendered the Dropdownlist and on change of dropdown value you have invoked the setRowData method of Grid which causing the edit form was not closed properly it was the cause of the problem.
To resolve your reported problem, we suggest you invoke the endEdit method of Grid to close the edit state properly in the Grid and then call the updateRow method instead of setRowData.
For your convenience we have attached a sample below to demonstrate the setup we used. Please refer the below code example, sample for more information.
|
private registerOnEmployeeChange() { this.formGroup ?.get('employeeId') ?.valueChanges.pipe( tap((employeeId) => { if (this.currentRowEdit) { const newRowData = { ...this.currentRowEdit, employee: { ...this.currentRowEdit.employee, id: employeeId, }, }; console.log(newRowData); if (this.grid?.isEdit) { //check whether the Grid is in edit state or not this.grid?.endEdit(); // setTimeout(() => { this.grid?.updateRow(this.currentRowIndex, newRowData); }, 0); } } }), takeUntil(this.destroy$) ) .subscribe(); }
|
Sample: https://stackblitz.com/edit/stackblitz-starters-zwsb1f?file=src%2Fmain.ts
Please get back to us if you need further assistance.
Regards,
Rajapandi R
Hello, I have tried as you said:
Niels,
In our previous update, we have provide the solution using our updateRow method but from reviewing your shared code information in your current update you have used the method name as updateRowValue, please refer the below screenshot for more information.
So, we kindly suggest defining the method name appropriately as updateRow. Additionally, in the registerOnEmployeeChange method, you have used switchMap, photosService, and tap, which were not present in your previously shared update sample. As we do not have information about these updates, we request you to share a reproducible sample of the issue along with your updated code changes. This will help us validate the scenario and provide an appropriate solution.
- 3 Replies
- 2 Participants
- Marked answer
-
NV Niels Van Goethem
- Dec 5, 2024 03:33 PM UTC
- Dec 14, 2024 10:55 AM UTC