Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 29 days ago.
I need to compare edited row data with the row just below edited row.
A table with 5 rows. When i am editing records from top to bottom in that order using below code i am able to store values that are edited in an array. Here latest edited value is stored at the last index of storeArray.
When i am editing records from bottom to top, the last edited record is now saved at 1st index but i want that there. It should also save the data like above i.e last edited value should be present at last index in the array
Similarly when it is edited in random order then also last edited value should be at last index of array.
Below is the code used to fetch and save edited values
const storeArray = _.reduce(this.allValuesArray, function(storeArray, value, key) {
return _.isEqual(value, this.allValuesArray[key]) ?
storeArray : storeArray.concat(allValuesArray[key]);
}, []);
Above method is called after editing few rows when the button Save is clicked.
allValuesArray = JSON having all row records fetched during ngOnInit
storeArray = The array in which i am storing the data that are being edited
Everything is done on Angular 5