datatable search via data attributes


Topic: datatable search via data attributes

Pierre Grobbelaar pro premium priority asked 3 years ago

I use php to fetch mysqli data to dynamically populate the table. I want the search function to search table content through data attributes.

I cant get it to filter the data because I don't know how to activate the function. Please provide a generic example of the search function using data attributes instead of javascript.Mdb basic table example


Dawid Wajszczuk staff answered 3 years ago

Hi,

You just need to write this JS code

const instance = mdb.Datatable.getInstance(document.querySelector('.datatable'));

document.querySelector('#datatable-search-input').addEventListener('input', (e) => {
  instance.search(e.target.value);
});

Here is the snippet https://mdbootstrap.com/snippets/standard/d-wajszczuk/3532745#js-tab-view.

Keep coding,
Dawid


Pierre Grobbelaar pro premium priority commented 3 years ago

Exactly what I was looking for. Thank you Dawid.


Mejuto answered 3 years ago

On the same spot, using datatable via attributes and need to seach, how to access to the row content via javascript?.

Thank you


Mejuto answered 3 years ago

Work perfect! Thank you.

Regards


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
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.9.0
  • Device: PC
  • Browser: Opera
  • OS: Windows
  • Provided sample code: No
  • Provided link: No
Tags