1

I'm trying to use a custom filter on one of my columns and to do the filtering programmatically. I have managed to call the custom filter but the filterVal prints as null. Code below:

Calling the filter:

yadcf.exFilterColumn(theTable, [[4, "Value To Filter On"]]);

The filter itself - I'm just returning true for now to test the actual calling of the filter:

function numberFilter(filterVal, columnVal, rowValues, stateVal) {
    console.log(filterVal)
    return true;
}

The console.log line prints out null instead of "Value to Filter On".

Am I missing something or is customFunc even supported with exFilterColumn?

Jack Boyle
  • 15
  • 5

1 Answers1

0

It wasn't working because you tried to filter with value that is not present in the filter values, in addition notice that you have used html elements in the column which resulted in html elements in the filter itself,

Here is the modified code for filter

$("#value-filter").on('input', function () { console.log(this.value); yadcf.exFilterColumn(theTable, [[0, 50]]); })

and updated column data

<tr> <td> 500 </td> </tr> <tr> <td> 200 </td> </tr> <tr> <td> 50 </td> </tr>

Daniel
  • 36,833
  • 10
  • 119
  • 200
  • Thank you, is there any way to pass a value that is not in the table to the customFilter using exFilterColumn. I wish to allow users to write custom queries e.g. Typing "<25" in to the search box would return all results less that 25. – Jack Boyle Feb 12 '18 at 09:27
  • not sure that its possible, you can try to debug to see where the code of yadcf should be tweaked and you can send a PR, or open a new feature request, something like "pass any query string" to the custom function / add new filter `filter_type: 'text_custom_func filter type'` – Daniel Feb 12 '18 at 09:57