Trouble Filtering With Ajax-populated Data

Trouble Filtering With Ajax-populated Data

randyesqrandyesq Posts: 2Questions: 0Answers: 0
edited March 2011 in General
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!

Replies

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin
    Interesting one - I'm honestly not sure what the issue is with this - the basic idea looks fine. Can I suggest you try 1.7.6 and see if that addresses the issue (from your initialisation there shouldn't be any difference). If that isn't an option, perhaps you can post a link so I can have a look at the live settings object for the table.

    > 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
  • randyesqrandyesq Posts: 2Questions: 0Answers: 0
    edited March 2011
    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
This discussion has been closed.