Topic: Event after search in datatable

pcrdev priority asked 1 year ago


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:

  1. Using "render.mdb.datatable" event
  2. Putting a timeout

Resources (screenshots, code snippets etc.)


Grzegorz Bujański staff answered 1 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
  });
});


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • 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