我已经使用dataTables设置了一个可搜索的表,它运行正常,接受一列未在搜索框中过滤。
这是我的JSFiddle
我正在努力的专栏是“模拟频道”栏目,例如,如果我在搜索框中键入“数字”,它将过滤所有数字结果。但是,如果我键入“analog”,它根本不会注册它。
继承我的桌子
<table cellspacing="0" cellpadding="4" id="table_id" class="scope-table">
<thead class="header">
<tr>
<th>Oscilloscope</th>
<th>Bandwidth (MHz)</th>
<th>Analog Channels</th>
<th>Digital Channels</th>
<th>List Price</th>
<th>Sale Price</th>
</tr>
</thead>
<tbody>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix-TBS1064.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/Tektronix-TBS1064.html">TBS1064</a></td>
<td>60</td>
<td>4 analog</td>
<td>0</td>
<td>£653.00</td>
<td>£555.05</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/copy_of_Tektronix_TBS1052B.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/copy_of_Tektronix_TBS1052B.html">TBS1072B</a></td>
<td>70</td>
<td>2 analog</td>
<td>0</td>
<td>£587.00</td>
<td>£498.95</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/copy_of_Tektronix_TBS1052-EDU.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/copy_of_Tektronix_TBS1052-EDU.html">TBS1072B-EDU</a></td>
<td>70</td>
<td>2 analog</td>
<td>0</td>
<td>£521.00</td>
<td>£442.85</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/TBS1102B.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/TBS1102B.html">TBS1102B</a></td>
<td>100</td>
<td>2 analog</td>
<td>0</td>
<td>£785.00</td>
<td>£667.25</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/copy_of_copy_of_Tektronix_TBS1052-EDU.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/copy_of_copy_of_Tektronix_TBS1052-EDU.html">TBS1102B-EDU</a></td>
<td>100</td>
<td>2 analog</td>
<td>0</td>
<td>£719.00</td>
<td>£611.15</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix-TBS1104.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/Tektronix-TBS1104.html">TBS1104</a></td>
<td>100</td>
<td>4 analog</td>
<td>0</td>
<td>£983.00</td>
<td>£835.55</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix_TBS1152B.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/Tektronix_TBS1152B.html">TBS1152B</a></td>
<td>150</td>
<td>2 analog</td>
<td>0</td>
<td>£983.00</td>
<td>£835.55</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix_MDO3032.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/copy_of_copy_of_copy_of_Tektronix_TBS1052-EDU.html">TBS1152B-EDU</a></td>
<td>150</td>
<td>2 analog</td>
<td>0</td>
<td>£917.00</td>
<td>£779.45</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix-TBS1154.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/Tektronix-TBS1154.html">TBS1154</a></td>
<td>150</td>
<td>4 analog</td>
<td>0</td>
<td>£1,180.00</td>
<td>£1,003.00</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix_TBS1202B.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/Tektronix_TBS1202B.html">TBS1202B</a></td>
<td>200</td>
<td>2 analog</td>
<td>0</td>
<td>£1,180.00</td>
<td>£1,003.00</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/copy_of_copy_of_copy_of_copy_of_Tektronix_TBS1052-EDU.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/copy_of_copy_of_copy_of_copy_of_Tektronix_TBS1052-EDU.html">TBS1202B-EDU</a></td>
<td>200</td>
<td>2 analog</td>
<td>0</td>
<td>£1,110.00</td>
<td>£943.50</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix_DPO2002B.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/Tektronix_DPO2002B.html">DPO2002B</a></td>
<td>70</td>
<td>2 analog</td>
<td>0</td>
<td>£866.00</td>
<td>£736.10</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix_DPO2004B.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/Tektronix_DPO2004B.html">DPO2004B</a></td>
<td>70</td>
<td>4 analog</td>
<td>0</td>
<td>£1,350.00</td>
<td>£1,147.50</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/DPO2012.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/DPO2012.html">DPO2012B</a></td>
<td>100</td>
<td>2 analog</td>
<td>0</td>
<td>£1,110.00</td>
<td>£943.50</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/DPO2014.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/DPO2014.html">DPO2014B</a></td>
<td>100</td>
<td>4 analog</td>
<td>0</td>
<td>£1,600.00</td>
<td>£1,360.00</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix_DPO2022B.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/Tektronix_DPO2022B.html">DPO2022B</a></td>
<td>200</td>
<td>2 analog</td>
<td>0</td>
<td>£1,560.00</td>
<td>£1,326.00</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/DPO2024.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/DPO2024.html">DPO2024B</a></td>
<td>200</td>
<td>4 analog</td>
<td>0</td>
<td>£1,930.00</td>
<td>£1,640.50</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix_MSO2002B.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/Tektronix_MSO2002B.html">MSO2002B</a></td>
<td>70</td>
<td>2 analog</td>
<td>16 digital</td>
<td>£1,500.00</td>
<td>£1,275.00</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix_MSO2004B.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/Tektronix_MSO2004B.html">MSO2004B</a></td>
<td>70</td>
<td>4 analog</td>
<td>16 digital</td>
<td>£1,960.00</td>
<td>£1,666.00</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/MSO2012.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/MSO2012.html">MSO2012B</a></td>
<td>100</td>
<td>2 analog</td>
<td>16 digital</td>
<td>£1,720.00</td>
<td>£1,462.00</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/MSO2014.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/MSO2014.html">MS02014B</a></td>
<td>100</td>
<td>4 analog</td>
<td>16 digital</td>
<td>£2,220.00</td>
<td>£1,887.00</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/Tektronix_MSO2022B.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/Tektronix_MSO2022B.html">MS02022B</a></td>
<td>200</td>
<td>2 analog</td>
<td>16 digital</td>
<td>£2,190.00</td>
<td>£1,861.50</td>
</tr>
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/MSO2024.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/MSO2024.html">MS02024B</a></td>
<td>200</td>
<td>4 analog</td>
<td>16 digital</td>
<td>£2,550.00</td>
<td>£2,167.50</td>
</tr>
</tbody>
</table>
我错过了什么?我应该初始化表搜索的字段数量? 有人可以指出我哪里出错吗?非常感谢。
答案 0 :(得分:1)
我必须承认,这种行为让我感到困惑。
但在看了你的小提琴后,我发现你的每一行都有analog
这个词。
因此:没有过滤,因为所有行都通过了过滤器。
尝试将其中一个数据集设置为完全不同的数据集(不包括单词analog),如:
<tr class="js-clickableRow" data-url="http://www.sjelectronics.co.uk/acatalog/copy_of_Tektronix_TBS1052B.html">
<td><a href="http://www.sjelectronics.co.uk/acatalog/copy_of_Tektronix_TBS1052B.html">TBS1072B</a></td>
<td>70</td>
<td>2 canonical</td>
<td>0</td>
<td>£587.00</td>
<td>£498.95</td>
</tr>
现在在搜索字段中输入ana
。
当您输入最后一个a
时,网格开始过滤。多数民众赞成因为{{1>}存在于 alog和c onical。
答案 1 :(得分:0)
问题的真正答案是:一切正常。
如上所述,每一行都包含“&#34; analog&#34;这就是为什么过滤&#34; analog&#34;似乎没有用。
我对该问题的原始理解是模拟通道列未按预期工作,即搜索
2 analog
不会过滤掉像4模拟这样的东西。该问题的解决方案是在搜索框中围绕搜索字词添加引号,如此
&#34; 2 analog&#34;
否则,DataTables将查找包含2或模拟的每一行。