Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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
Jquery 筛选DataTables.net中包含下拉列表的列_Jquery_Datatables - Fatal编程技术网

Jquery 筛选DataTables.net中包含下拉列表的列

Jquery 筛选DataTables.net中包含下拉列表的列,jquery,datatables,Jquery,Datatables,我想知道是否可以通过DataTables.net过滤包含下拉列表的列。例如: <table id="example" class="display" cellspacing="0" width="100%"> <thead> <tr> <th>Name</th> <th>Position</th> <th>Office</th>

我想知道是否可以通过DataTables.net过滤包含下拉列表的列。例如:

<table id="example" class="display" cellspacing="0" width="100%">
<thead>
    <tr>
        <th>Name</th>
        <th>Position</th>
        <th>Office</th>
        <th>Item requested</th>
    </tr>
</thead>
<tfoot>
    <tr>
        <th>Name</th>
        <th>Position</th>
        <th>Office</th>
        <th>Item requested</th>
    </tr>
</tfoot>
<tbody>
    <tr>
        <td>Tiger Nixon</td>
        <td>System Architect</td>
        <td>Edinburgh</td>
        <td>
    <select id="ItemRequested" name="ItemRequested">
        <option value="FO">Foo</option>
        <option value="BA">Bar</option>
        <option selected="selected" value="WI">Widget</option>
    </select>
</td>
    </tr>
    <tr>
        <td>Joe Bloggs</td>
        <td>Software Engineer</td>
        <td>London</td>
        <td>
    <select id="ItemRequested" name="ItemRequested">
        <option value="FO">Foo</option>
        <option selected="selected" value="BA">Bar</option>
        <option value="WI">Widget</option>
    </select>
</td>
    </tr>
</tbody>

名称
位置
办公室
请求的项目
名称
位置
办公室
请求的项目
老虎尼克松
系统架构师
爱丁堡
福
酒吧
小装置
乔·布洛格斯
软件工程师
伦敦
福
酒吧
小装置

我需要能够搜索每个下拉列表的选定值

任何帮助都将不胜感激


谢谢。

试试这样:


$(文档).ready(函数(){
var数据=[];
数据推送(
[1,“萨沙”、“布伦纳”、“0800 1111”],
[2,“Sage”、“Mia”、“01012)405872”],
[3,“Chelsea”,“Allistair”,“076 0578 0265”],
[4,“Uta”、“萨凡纳”、“070 1247 5884”],
[5,“补救措施”,“伯克”,“0995 181 0007”],
[6,“鲁比”,“韦恩”,“0800 1111”],
[7,“信仰”,“弗雷德里卡”,“01709)099879”],
[8,“迈拉”、“哈里森”、“07042419576”],
[9,“德雷克”、“米里亚姆”、“0800 733635”],
[10,“里德”,“香农”,“076 8597 5067”]
);
var计数=0;
$('数据表')。数据表({
数据:数据,
initComplete:函数(){
this.api().columns().every(函数(){
/*如果(计数=2)
{*/
var列=此;
变量选择=$(“”)
.appendTo($(column.footer()).empty())
.on('change',function(){
var val=$.fn.dataTable.util.escapeRegex(
$(this.val()
);
柱
.search(val?“^”+val+“$”:“”,true,false)
.draw();
});
column.data().unique().sort().each(函数(d,j){
选择。追加(“”+d+“”)
});
/*}*/
计数++;
});
}
});
});
.奇怪{
背景色:#FFF8FB!重要;
}
.甚至{
背景色:#DDEBF8!重要;
}
电磁脉冲代码
名字
姓
可移动的

Mayank,我认为提出的解决方案不是Diz想要的。作为一个用户,我希望能够根据从下拉列表中选择的值筛选行。我想使用一个过滤框对所有列进行过滤。更重要的是,其中一列将有选择框,而不仅仅是文本。