Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yadcf filter with select tag inside column

I have a table (using datatables framwork) which contains in a column tag. I mean that content of this columns looks like this:

<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 yadcf column filter and try to search only columns wih "Yes" as selected options in this select, it doesn't work because every rows contains "Yes" in html code.

Can you please help me, how to set yadcf for solving this issue if it's possible?

Thank you

like image 237
west44 Avatar asked Oct 29 '22 14:10

west44


1 Answers

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

From inline docs: (reformatted explanation )

custom_func

Required: true, when filter_type is custom_func
Type: function
Default value: undefined
Description: should be pointing to a function with the following signature

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

}

where filterVal: is the value from the select box,
columnVal is the value from the relevant row column,
rowValues is an array that holds the values of the entire row and
stateVal which holds the current state of the table row DOM
, stateVal is perfect to handle situations in which you placing radiobuttons / checkbox inside table column (should be suitable for your case of select.

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

like image 75
skadya Avatar answered Nov 15 '22 14:11

skadya