Category: How do I do X?
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.

Set back format row after saving (Table inline editing)

Issue

I am having trouble with an editable table. Whenever I edit a row and save the changes, the row stays in an editable state. I need to know how to set it back to normal mode after saving the changes.

Resolution

To set the edited row back to normal mode after saving changes, you can fetch the new data from the backend and refresh the table with the updated data. This should remove the editable state and display the updated information.

Here is an example code snippet that demonstrates this approach:

function saveChanges(rowId) {
// make API call to update data in database
// ...

// fetch updated data from backend
fetch('/api/getData')
.then(response => response.json())
.then(data => {
// update table with new data
const table = document.querySelector('#myTable');
table.innerHTML = generateTableHTML(data);
});
}

function generateTableHTML(data) {
// generate table HTML with updated data
// ...
}

In this example, the saveChanges function is called when the user clicks the "Save" button to update the row data in the database. After the API call is made to save the changes, the function fetches the updated data from the backend using the fetch method. Once the data is successfully retrieved, the generateTableHTML function is called to generate the table HTML with the new data. Finally, the innerHTML property of the table element is updated with the new HTML, which should remove the editable state and display the updated information.