react-bootstrap-table icon indicating copy to clipboard operation
react-bootstrap-table copied to clipboard

Help save to DB

Open Abuitime opened this issue 9 years ago • 6 comments

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 avatar Jan 12 '17 00:01 Abuitime

@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 avatar Jan 12 '17 01:01 AllenFang

@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

Abuitime avatar Jan 12 '17 01:01 Abuitime


// in your function
my_function() {
    this.refs.table.getTableDataIgnorePaging()  // that's all the data in table
}


<BootstrapTable ref='table'>

AllenFang avatar Jan 12 '17 01:01 AllenFang

@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

Abuitime avatar Jan 13 '17 22:01 Abuitime

nvm, I forgot about cellName!

Abuitime avatar Jan 13 '17 22:01 Abuitime

This was super helpful. Thanks!

stevenqzhang avatar Nov 29 '17 08:11 stevenqzhang