Topic: datatable search via data attributes
Pierre Grobbelaar 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.
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
Mejuto free 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
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- 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