Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从yadcf列(搜索)过滤器中排除隐藏元素?_Javascript_Yadcf - Fatal编程技术网

Javascript 如何从yadcf列(搜索)过滤器中排除隐藏元素?

Javascript 如何从yadcf列(搜索)过滤器中排除隐藏元素?,javascript,yadcf,Javascript,Yadcf,我正在使用yadcf过滤器插件,代码如下 HTML: <table id="myTable"> <thead> <tr> <th>xyz</th> </tr> </thead> <tbody> <tr> <td> <span> <span id=

我正在使用yadcf过滤器插件,代码如下

HTML:

<table id="myTable">
  <thead>
    <tr>
      <th>xyz</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
        <span>
          <span id="eg1">abc</span>
          <span id="eg2" style="display: none;">fgd abc wew</span>
        </span>  
      </td>
    </tr> 
    <tr>
      <td>
        <span>
          <span id="eg3">wew</span>
          <span id="eg4" style="display: none;">fgd abc wew</span>
        </span>  
      </td>
    </tr>
  </tbody>
</table>
$(document).ready( function () {
    let dataTable = $('#myTable').DataTable();
    yadcf.init(dataTable, [{
        column_number: 0,
        filter_type: 'multi_select',
        select_type: 'select2',
        column_data_type: 'html',
        html_data_type: 'selector',
        html_data_selector: 'span:eq(0)',
    }], );  
});
如何从yadcf列(搜索)筛选器中排除隐藏元素? 我不知道怎么做。请帮忙。提前谢谢


JSFIDDLE:

您可以使用
过滤器类型:'multi\u select\u custom\u func'
(您仍然需要应用您的逻辑)

参见示例代码

$(document).ready( function () {
    let dataTable = $('#myTable').DataTable();
    yadcf.init(dataTable, [{
            column_number: 0,
        filter_type: 'multi_select_custom_func',
        custom_func: myCustomFilterFunction,
        select_type: 'select2',
        column_data_type: 'html',
        html_data_type: 'selector',
        html_data_selector: 'span:eq(0)'
    }], );
    
    function myCustomFilterFunction(filterVal, columnVal, rowValues, stateVal) {
        //apply logic here
        console.log(columnVal);
        console.log(stateVal);
    }
});
看到它工作(您仍然需要应用您自己的逻辑)

这是我的自定义函数

函数multiSelectCustomFilterFunction(filterVal,columnVal){
const item=columnVal.trim().split(//[\t]{5,}/g)[0];//选择第一个可见的内部span标记
filterValArray=[];
过滤式前刀(修整器);
功能微调器(值){
filterValArray.push(value.trim());//删除值周围的额外空间
}
return filterValArray.length!=0?filterValArray.includes(item.trim()):true;//以匹配所选数据和可用数据
}

JSFIDDLE:

如果使用列数据类型作为呈现html呢?我也使用了它。但是,它不起作用。请提供一个最小的JSFIDLE示例页面,以便我可以尝试help@Daniel你好,这是我的JSFIDLE是的。。谢谢,我也这么做了!