Category: Question and Answers
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How to get all table data when inline editing a couple of rows?

Issue

I have a table that is populated by a query and I updated one column of some rows in it. Now I have a list of updated rows and an unedited data set. I want to get all rows, including the modified and unmodified ones. I tried traversing the data rows and checking if their index exists in the list of updated rows, but it didn't work. I'm looking for a better solution.

Resolution

The user has a table that is populated by a query and they updated one column of some rows inside it. They have two JSON objects - updatedRows which has only the updated rows, and data which has the unedited data. They want to get all rows (existing unmodified & modified rows). However, when they tried traversing the data rows and checking the index if it exists in the updatedRowIndices array, all .indexOf(key) return -1, like the key isn’t there. A possible solution suggested on Discord is to merge the data from the two JSON objects if the user needs the unmodified and modified rows. The following is an example code for merging two JSON objects in JavaScript:

var mergedJSON = {...data, ...updatedRows};

This code creates a new object mergedJSON and spreads both data and updatedRows into it, merging them into a single JSON object. With this solution, the user can access all the rows, modified and unmodified.