我已经让DataTables jQuery 插件工作了,它的插件ColumnFilterWidgets在大多数情况下成功地过滤了结果。
但是,当我尝试过滤的单元格/列包含 HTML 时,我遇到了问题——在我的例子中,是逗号分隔的超链接。下拉选择已正确创建,但每个选项不仅包含文本,还包含完整的超链接代码。当过滤器运行时,它不返回任何结果。
这个问题显然已经存在了一段时间,但我尝试过的任何方法都没有解决它(包括该线程中的修复)。
这是我初始化数据表并设置过滤器的代码:
var oTable = $('#pub_table').dataTable( {
"oLanguage": {
"sSearch": "<h5><i class='icon-search icon-large'></i> Search Publications</h5>"
},
"sDom": 'W<"clear">lfrtip',
"oColumnFilterWidgets": {
"sSeparator": ", ",
"aiExclude": [ 0 ],
"bGroupTerms": true,
}
} );
我的表代码是 php 生成的,但很简单,这是数据表正在使用的结果数据集的示例:
<table id="pub_table" width="100%" class="pretty">
<thead>
<tr>
<th class="resource_title">Resource</th>
<th class="resource_libraries">Library</th>
<th class="resource_audiences">Target Audience</th>
<th class="resource_topics">Topic</th>
<th class="resource_types">Type</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/resources/a-video-resource/" rel="bookmark" title="A video resource">A video resource</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/libraries/advocacy/" rel="tag">Advocacy</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/audiences/staff/" rel="tag">Staff</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/topics/sample-topic-2/" rel="tag">Sample topic 2</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/types/download/" rel="tag">Download</a>, <a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/types/video/" rel="tag">Video</a></td>
</tr>
<tr>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/resources/social-media-guidelines-and-best-practices/" rel="bookmark" title="Social Media Guidelines and Best Practices">Social Media Guidelines and Best Practices</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/libraries/advocacy/" rel="tag">Advocacy</a>, <a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/libraries/board-governance/" rel="tag">Board Governance</a>, <a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/libraries/program-administration/" rel="tag">Program Administration</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/audiences/board-members/" rel="tag">Board Members</a>, <a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/audiences/staff/" rel="tag">Staff</a>, <a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/audiences/stakeholders/" rel="tag">Stakeholders</a>, <a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/audiences/volunteers/" rel="tag">Volunteers</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/topics/sample-topic-1/" rel="tag">Sample topic 1</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/types/article/" rel="tag">Article</a></td>
</tr>
<tr>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/resources/brand-guidelines/" rel="bookmark" title="Brand Guidelines">Brand Guidelines</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/libraries/program-administration/" rel="tag">Program Administration</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/audiences/board-members/" rel="tag">Board Members</a>, <a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/audiences/staff/" rel="tag">Staff</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/topics/sample-topic-1/" rel="tag">Sample topic 1</a></td>
<td><a href="http://mwamp.1505garnaas.net/texascasa/wp/blog/types/download/" rel="tag">Download</a></td>
</tr>
</tbody>
<tfoot>
<tr>
<th class="resource_title">Resource</th>
<th class="resource_libraries">Library</th>
<th class="resource_audiences">Target Audience</th>
<th class="resource_topics">Topic</th>
<th class="resource_types">Type</th>
</tr>
</tfoot>
我已经进行了广泛的搜索,但无法弄清楚这一点。我对 jQuery 还很陌生,这无济于事。:) 任何指针?谢谢!