Defining the search value for a column
Defining the search value for a column
I can't believe I spent the last hour for searching without success an in my opinion simple and common problem: All I want is to define the value that shall be used for DT to search in a specific column. In other words, if you set up a table in static HTML you can define via https://datatables.net/examples/advanced_init/html5-data-attributes.html HTML data-attributes. But how do you do it if you do NOT use static HTML, when DT gets it's rowset data from a JavaScript variable?
columns: [{ title: 'Date', data:{"_": 'hrDate', 'sort': 'timestamp'} }]
works fine for setting sorting value. But how do I set the search value (equivalent to HTML attribute data-search)?
Answers
Use columns().search()
https://datatables.net/reference/api/columns().search()
Example:
I have a couple of buttons that search for a certain value in only one column that is identified by an id in the HTML. I turned off "smart search" because in my use case it doesn't make sense.
This is what it looks like:
You don't have your syntax correct for the Orthogonal data. Instead of using
columns.data
you need to usecolumns.render
. See the Predefined values section.Kevin