Topic: Event after search in datatable
Expected behavior
I am trying to find out a way to call a function after datatable search is complete.
Actual behavior
There is no event that help me hide the loader that I opened after I called for search in datatable.
Here are the things I attempted:
- Using "render.mdb.datatable" event
- Putting a timeout
Resources (screenshots, code snippets etc.)
Grzegorz Bujański staff answered a year ago
We do not have a dedicated event that will fire after the search action. You can use the render.mdb.datatable
event for this.
You can also do the whole thing inside the search function. If I understand correctly, inside the search function you send a query to the API and you have to wait for data? So you can do something like this:
document.getElementById('datatable-search-input').addEventListener('input', (e) => {
// show loader
fetch('server_url')
.then((response) => response.json())
.then((data) => {
// update datatable data
// hide loader
});
});
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 6.4.2
- Device: ANY
- Browser: ANY
- OS: ANY
- Provided sample code: No
- Provided link: No