Problem Statement :
In below stackblitz demo, I am able to insert the FormGroup
dynamically at the starting of the grid on clicking the Add
button and triggering the (blur)
event from one control to update the value of another control sharing same rowIndex
. Now the issue is if i inserted multiple formGroups
and trigger on (blur)
event on any of the newly added FormGroups
it updates the value of other controls as well having different rowIndex
.
Steps to reproduce the issue :
- Open the below demo link.
- Add multiple rows (2 rows) by clicking on the Add button.
- Enter the value in name field of the 2nd newly added row and focus out.
- It updates the age field in both the newly added row instead of only in second one.
Stackblitz Demo : https://stackblitz.com/edit/angular-oitz5j-4uezqr
Requirement :
Tab out on any name field of particular row, Age field on same row should display a random number without impacting other rows.
What i tried so far ?
Tried to use Array unshift() method but getting error
Property 'unshift' does not exist on type 'FormArray'
Tried to use FormArray.insert() method.It will work if we want to add a
FormGroup
at specific index. But it fails to insert multipleFormGroups
on the top ofFormArray
dynamically.
Update : Above issue is working fine without Kendo Grid. Please check the below demo.
Demo : https://stackblitz.com/edit/angular-oitz5j-2a31gs
Related issues in github/stackoverflow :
https://github.com/angular/angular/issues/16322
Angular - Form Array push specific index
Note : If we are going to add the controls at the end of the Grid, it is working like a champ. Please check the below demo which works fine with adding the controls at the last.
addNewRow()
twice to add row andonFocusOut(1)
to mock the expected behavior and everything works fine ! – FrinkaddNewRow()
function and thesubscription
also. – Frink