Help save to DB
Hello Allen,
Can you point me in the right direction or guide me through how I can take what the user edited in the cell and save and update the DB. I am wondering if there is already some functionality implemented within the API that does something similar...
Thank you, Alex
@Abuitime, firstly, react-bootstrap-table can't help you to save the data into database, it's only a component, but we support a lots of hooks for you can take the data after or before the event trigger.
Back to your case, you can add afterSaveCell in cellEdit prop, check this example, so that you can call the API that user changed in the callback function of afterSaveCell.
BTW, you are supposed to know the redux(A flux implementation), many of people develop react application with redux, which is a state management with a single direction and some feature. if you use redux, you need to call a api from action and manage your state in your store.
Let me know if you still have some trouble.
@AllenFang
Thank you, that example helped! Is there a way to grab all the data that is used in the table?
For example, I am populating the table with data...once the table is edited...grab all data from the table.
I am trying to save the data into the DB with a save button as oppose to making individual calls to the DB every time the cell is saved.
Alex
// in your function
my_function() {
this.refs.table.getTableDataIgnorePaging() // that's all the data in table
}
<BootstrapTable ref='table'>
@AllenFang
Thank you,
Is there support for seeing what column was changed when onAfterSaveCell() is called?
I think currently it gets the whole row object and cell value...
Thank you, Alex
nvm, I forgot about cellName!
This was super helpful. Thanks!