Trouble Filtering With Ajax-populated Data
Trouble Filtering With Ajax-populated Data
I have a datatable using the following code:
[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"
}]
});
[/code]
My server sends back the JSON correctly and the table populates as expced (have I said yet that I love this lib?).
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:
[code]
<!--Test List Table-->
<!--Table Header-->
Protocol/Test/Case
Last Run
Last Build/Phase
Detail
Owner
<!--Table Body, ajax populated, see /media/custom_js/user_dashboard.js -->
[/code]
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 datatables 1.6.2.
Thanks!
[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"
}]
});
[/code]
My server sends back the JSON correctly and the table populates as expced (have I said yet that I love this lib?).
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:
[code]
<!--Test List Table-->
<!--Table Header-->
Protocol/Test/Case
Last Run
Last Build/Phase
Detail
Owner
<!--Table Body, ajax populated, see /media/custom_js/user_dashboard.js -->
[/code]
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 datatables 1.6.2.
Thanks!
This discussion has been closed.
Replies
> Is the JSON data that was sent supposed to be populated there?
No - it's done "after the fact". View source will just show the HTML as it was loaded by the server. If you want to see the HTML that has been modified by Javascript, then you'll need something like Firebug.
Allan
Actually I have dug deeper and found something even stranger. I have this code running on a dev and a prod server and it is only on the prod server where I am seeing the problem.
The issue is in the regex search around line 3161 in _fnFilter:
[code]
/* Search through all records to populate the search array
* The the oSettings.aiDisplayMaster and asDataSearch arrays have 1 to 1
* mapping
*/
for ( i=0 ; i