How to search multiple columns using REACT
How to search multiple columns using REACT
aChinchilla
Posts: 9Questions: 3Answers: 0
I am trying to accomplish these lines of code but with REACT
$.fn.dataTable.ext.search.push(
function( settings, searchData, index, rowData, counter ) {})
so basically inside here:
const ctReadyHandler = function (e) {
let datasetId = e.datasetId;
let domId = e.domId;
let editor = e.editor;
let table = e.table;
//CUSTOM SEARCH HERE
table.ext.search.push ?????
}
This question has an accepted answers - jump to answer
Answers
Hi,
$.fn.dataTable.ext.search
is global - i.e. it applies to all tables on the page, so you would use the same$.fn.dataTable.ext.search
array.However, it looks like you are using CloudTables. I would encourage you not to modify it like that. Use the built in SearchBuilder or SearchPane control.
Allan
Hi @allan ,
Thanks for the reponse, I think a searchbuilder is also good. To give context here is what I'm trying to accomplish. It's very simple.
In this demo, you will see a table and simply I want to create a predefined search/filter that filters/searches the table upon loading to say where item = chairs or tables.
https://prod.d314z4ftewc4me.amplifyapp.com/
below is my code so far.
As you see in the code, on line 18 I want to begin the init of a searchbuilder with predefined search/filter. My biggest obstacle is I can't seem to figure out how to access the searchBuilder API?
Yup - with DataTables, that's straightforward. However, not so much with CloudTables which is not designed for that kind of customisation I'm afraid. There is no way to specify customised configuration options for the DataTable when using CloudTables - it is entirely managed via the UI.
What you can do is limit the data in the data set completely, which might do what you want. That's called conditional data access and effectively filters the table.
Allan
Hi @allan ,
I like server side filtering better and I can probably figure this out. However I have to ask, are there any code examples out there showing a very simple case/example of this?
Thank you in advance.
-Abel
Basically this but with server-side processing enabled? I don't think there are actually, but I've knocked this together to show it working.
Allan
Hi @allan ,
thanks for the code!
-Abel