datatables - yadcf 过滤器在列内带有选择标签

标签 datatables filtering yadcf

我有一个包含在列标记中的表(使用数据表框架)。我的意思是该列的内容如下所示:

<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>

当我使用 yadcf 列过滤器并尝试在此选择中仅搜索"is"作为选定选项的列时,它不起作用,因为每行在 html 代码中都包含"is"。

你能帮我吗,如果可能的话,如何设置 yadcf 来解决这个问题?

谢谢

最佳答案

您可能需要定义过滤器类型“custom_func”并为您的列指定自定义过滤器函数。

来自 inline docs: (重新格式化的解释)

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.

关于datatables - yadcf 过滤器在列内带有选择标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41383746/

相关文章:

datatables - 插件 “yadcf”不适用于数据表

jQuery dataTables 1.10.5 自定义属性

php - 数据表:根据数据库值隐藏列

Django - 将选择字段限制为外部表的查询集?

python - 获取包含字符串元素的列表,不包括以初始列表中的任何其他元素为前缀的元素

wpf - WPF Datagrid 中的排序和过滤选项?

jquery - 当搜索未返回结果时,Select2 过滤器值消失

datatables - yadcf 插件不过滤数据

javascript - DataTables JS 在 PHP 应用程序中无法正确排序日期

javascript - 触发按钮时从数据表中的行获取下拉选定值