It is very common for retool users to want to replicate the look and feel of a "spreadsheet". Although I often advise clients to try and embrace the options that retool gives in terms of adding new records, visualising data and interacting with tables, I also try to replicate the experience that they've had for many many years, i.e. a spreadsheet.
On this tutorial I provide some tips on how you can make a Retool Table component "feel more" like a spreadsheet (it will never be a spreadsheet though!), whilst at the same time updating your database in the backend.
Here's the app shown in the video which you can import to see the snippets, which I also report below:
excel-feel-tutorial.json|attachPreformatted text
ment (26.4 KB)
This tutorial makes use of
- Scripts as Handle events
- Temporable variables
- setIn and setValue methods to update the variable
- Row buttons
Code Snippets:
Chance Cell
const index = table1.selectedDataIndex
const key = Object.keys(table1.changesetArray[0]).find(k => k !== "id");
const value = Object.entries(table1.changesetArray[0]).find(([key]) => key !== "id")[1];
updateUser.trigger({
onSuccess: () => { tableData.setIn([index,key],value);
}
});
Delete Cell
let updatedArray = [...tableData.value];
updatedArray.splice(table1.selectedDataIndex, 1);
deleteUser.trigger({
onSuccess: () => { tableData.setValue(updatedArray);
}
});