Ajax function with full data in DB
Ajax function with full data in DB
Link to test case https://codepen.io/mnk85/pen/gOypjdd**:
**Description of problem:
I really need your help. I'm exploring Datatable and I must confess I'm struggling a lot .
The goal is to use the "StatesRestore" feature of my table with my database. Everything is directly connected to the database (load, remove, save, rename). I tried to follow the official documentation and therefore used Ajax functions to achieve this.
At the moment of writing this message, I have one problem with the "remove" action. When I create a state, it appears with a name like "State 2" and an API call is made to save this state in the database. No problem so far. The issue is that if I want to perform an action on this state (for example, deleting it), it doesn't work because the state doesn't have the ID of my database in its data.
I've tried everything (latest attempt below) to provide it with this ID (which I do have in my API response) but it doesn't work.
const saveResponse = await callAPI('/stateSave', 'POST', tokenbis, userId, 'post_tab_state', requestData);
if (saveResponse && saveResponse.success) {
requestData.state.stateRestore.id = saveResponse.data.id_state;
console.log('New state saved with data', requestData);
callback({
state: requestData.state
});
}
Can you tell me how to give it the ID from my API response so that I can delete this state? Currently, I have to reload the entire page to delete it (my load action properly loads the data with the ID).
I've put all the code on CodePen, so you can see the code logic clearly.
Answers
I don't know if it can help but I have the impression that I'm "loading" the data incorrectly for the datatable.
I have the name(s) of the states that I loaded but I cannot modify them either and no state changes when I click on the different states.
Below is the raw code that I will process next:
Once processed, this is what I send to the datatable:
no one get this situation ?