When comparing the data of an edited row with the row just below it, I encounter a specific scenario. In a table containing 5 rows, as I edit records from top to bottom using the provided code snippet, I am able to store the values in an array. The most recent edited value is positioned at the end of the array.
However, when I edit records from bottom to top, the last edited record gets stored at the first index of the array. My goal is to ensure that the latest edited value always remains at the last index of the array, regardless of the order in which the records are edited.
To achieve this functionality, the following code snippet is utilized:
const storeArray = _.reduce(this.allValuesArray, function(storeArray, value, key) {
return _.isEqual(value, this.allValuesArray[key]) ?
storeArray : storeArray.concat(allValuesArray[key]);
}, []);
This method is invoked when the 'Save' button is clicked after editing multiple rows.
allValuesArray: JSON object containing all row records fetched during ngOnInit
storeArray: Array used to store the edited data
All these operations are performed within Angular 5 environment.