Select column for range filter dynamically
Select column for range filter dynamically
I would like to use the following code to apply a range filter on a few columns.
https://datatables.net/examples/plug-ins/range_filtering.html
For the webpage I am working on, each page has a different table. I would like to be able to specify the columns to add a range filter to on the server-side, and have that information passed back to the client, and then have the javascript generate range-filters for the columns.
Example: Response: [1,3,5] -> Javascript adds range filter to data[1], data[3], data[5]
Alternative suggestions are welcome also, the overall goal is to add the range filter without hardcoding the column number.
Answers
The Search Plugin development docs explain the parameters passed into the function. For the example you linked the
data
parameter is an array containing the data for each column. In the example the array size is 6.data[0]
represents column 0, etc.One option is to use global variables to determine the column, for example:
Then use
data[col0]
.Also this thread may have suggestions to help.
Kevin