使用 Jquery 数据表过滤 Ajax 填充的数据时出现问题
我有一个使用以下代码的 jquery 数据表:
// Test list table
$('#dashboard_testlist_table').dataTable({
"bJQueryUI": true,
"bAutoWidth": false,
"bProcessing": true,
"aaSorting": [[0, 'asc'], [2, 'asc']],
"sPaginationType": "full_numbers",
"sAjaxSource": projectTestListTablePopulateUrl,
"oLanguage": {
"sSearch": "Search all columns:"
},
"aoColumns": [{
"sTitle": "Protocol/Test/Case"
}, {
"sTitle": "Last Run"
}, {
"sTitle": "Last Build/Phase"
}, {
"sTitle": "Detail",
"sClass": "center"
}, {
"sTitle": "Owner"
}]
});
我的服务器正确发回 JSON,并且该表按预期填充。
我遇到的问题是我无法在表中进行任何过滤。搜索框中的任何字符都会立即过滤,不显示任何结果。我使用过很多数据表,而这个让我发疯。
我注意到,当我“查看页面源代码”时,源代码中没有呈现的 html。这是我的原始 HTML:
<!--Test List Table-->
<table id="dashboard_testlist_table" class="display">
<!--Table Header-->
<thead>
<tr>
<th>Protocol/Test/Case</th>
<th>Last Run</th>
<th>Last Build/Phase</th>
<th>Detail</th>
<th>Owner</th>
</tr>
</thead>
<tbody>
<!--Table Body, ajax populated, see /media/custom_js/user_dashboard.js -->
</tbody>
</table>
页面加载后,它仍然显示相同的内容。发送的 JSON 数据是否应该填充在那里?
否则,有人对过滤这些数据时首先要寻找什么有任何建议吗?我正在使用 jquery 数据表 1.6.2。
I have a jquery datatable using the following code:
// Test list table
$('#dashboard_testlist_table').dataTable({
"bJQueryUI": true,
"bAutoWidth": false,
"bProcessing": true,
"aaSorting": [[0, 'asc'], [2, 'asc']],
"sPaginationType": "full_numbers",
"sAjaxSource": projectTestListTablePopulateUrl,
"oLanguage": {
"sSearch": "Search all columns:"
},
"aoColumns": [{
"sTitle": "Protocol/Test/Case"
}, {
"sTitle": "Last Run"
}, {
"sTitle": "Last Build/Phase"
}, {
"sTitle": "Detail",
"sClass": "center"
}, {
"sTitle": "Owner"
}]
});
My server sends back the JSON correctly and the table populates as expected.
The problem that I am having is that I can not do any filtering whatsoever in my table. Any character in the search box immediately filters to no results being displayed. I have used many datatables and this one is driving me crazy.
I have noticed that when I "View Page Source", there is no rendered html in the source. Here is my original HTML:
<!--Test List Table-->
<table id="dashboard_testlist_table" class="display">
<!--Table Header-->
<thead>
<tr>
<th>Protocol/Test/Case</th>
<th>Last Run</th>
<th>Last Build/Phase</th>
<th>Detail</th>
<th>Owner</th>
</tr>
</thead>
<tbody>
<!--Table Body, ajax populated, see /media/custom_js/user_dashboard.js -->
</tbody>
</table>
After the page is loaded, it still shows the same. Is the JSON data that was sent supposed to be populated there?
Otherwise, does anyone have any suggestions on what to look for first with filtering this data? I am using jquery datatables 1.6.2.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否在服务器端页面中使用了搜索查询,
例如这样
did u use search query in your server side page
exaple like this
实际上,问题最终是我在 JSON(链接)中传递的一些 html,该 html 被放置到表中的一个
td
元素中。它畸形并引起头痛。Actually, the problem ended up being some html that I was passing in the JSON (a link) that was placed into one of the
td
elements in the table. It was malformed and was causing the headache.