Yadcf filter with highlighted tag inside column

I have a table (using the datatables framework) that is contained in a column tag. I mean, the contents of these columns are as follows:

<td> <select class="form-control attendance_select" data-id_player="130"> <option value="-1">No</option> <option value="0" selected="">No answer</option> <option value="1">Yes</option> </select> </td> 

When I use the yadcf column filter and try to search only the columns with β€œYes” as the selected options in this select, this does not work because each row contains β€œYes” in the html code.

Can you help me how to install yadcf to solve this problem, if possible?

thanks

+5
source share
1 answer

You probably need to define the filter type "custom_func" and specify the function of the custom filter for your column.

From the embedded documents: (reformatted explanation)

custom_func

Required: true when filter_type is custom_func
Type: function
Default value: undefined
Description: must point to a function with the following signature

 function myCustomFilterFunction(filterVal, columnVal, rowValues, stateVal) { } 

where filterVal : this is the value from the select box,
columnVal - the value from the corresponding column of the row,
rowValues is an array that contains the values ​​of the whole row and
stateVal that contains the current state of the row of the DOM table
, stateVal is ideal for handling situations in which you place radio buttons / checkbox inside a table column (should be suitable for your select case.

This function should return true if the string matches your condition and the string should be displayed) and false otherwise.

+2
source

Source: https://habr.com/ru/post/1262040/


All Articles