Filter not working After destroy and initialize the table
Filter not working After destroy and initialize the table
ashiquem01
Posts: 24Questions: 5Answers: 0
Dear Team,
Imagine a scenario where I am adding data from a popup. Once I click the submit button, the data is saved to the database, and the datatable is destroyed. Then, I call the GetAPI to fetch the data again, and it populates correctly. However, the problem I'm facing is that the data is not being filtered as external drop down.
This question has accepted answers - jump to:
Answers
Your example doesn't appear to demonstrate the issue described? It doesn't do a destroy at all.
Might your destroy be removing the event listener on your select perhaps? Failing that, if you could update the test case to show the issue, that would be great.
Also worth noting that you want to avoid destroying the DataTable if you can. If the new data's structure is the same as before, just use
clear()
androws.add()
to display the new data (orajax.reload()
if you are usingajax
to load the data).Allan
@allan Can you please check function OnSuccess(response).
I am calling GetApi from OnSuccess after Data Added
That's a lot of code! Please can you update your test case to demonstrate the issue you want help with, that'll be easiest way for us to debug it.
Colin
Thanks, @allan The execution of ajax.reload(); is running smoothly.
I have a question. I invoked the data table function within $(document).ready.
In the scenario where GetAPI returns a "bad request" response, how can I handle this situation?
Normally we use
AjaxCOde........
success: function (result) {
initializeDataTable(result.data)
}
Now I am using below code and ajax.reload() is working finely
The
400 Bad Request
is a response from the server. First start by looking at the server logs for the error to see why its responding with the 400 error. Let us know what you find.Kevin
@kthorngren
All functions of DataTables are working for me.
I recently asked a question about handling AJAX calls with the success function, which is typically used to process the API response, whether it succeeds or fails. I need guidance on how to implement this in the following code.
You can't use the
success
function ofajax
- as the manual says:There are two options there, or you can use one of the events, such as
xhr
perhaps,Colin