fnDraw() has no effect
fnDraw() has no effect
Hello everyone,
The problem that I'm having is that fnDraw() doesn't do anything. Moreover, when I put a simple alert() after the fnDraw(), the alert never fires. Here's a copy of my initialization script:
[code]oTable = $('#people').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": false,
"bServerSide": true,
"sAjaxSource": "../include/php/people_table.php",
"aaSorting": [[ 2, 'ASC' ]]
});[/code]
No matter how I call the fnDraw() function, nothing happens. Any ideas?
Thank you very much for taking the time to read this post.
Kevin
The problem that I'm having is that fnDraw() doesn't do anything. Moreover, when I put a simple alert() after the fnDraw(), the alert never fires. Here's a copy of my initialization script:
[code]oTable = $('#people').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": false,
"bServerSide": true,
"sAjaxSource": "../include/php/people_table.php",
"aaSorting": [[ 2, 'ASC' ]]
});[/code]
No matter how I call the fnDraw() function, nothing happens. Any ideas?
Thank you very much for taking the time to read this post.
Kevin
This discussion has been closed.
Replies
Kevin
1. fnDraw() with no effect - if an alert isn't even showing up after a call to fnDraw(), then there is one of two things like to be happening: a. there is a Javascript or JSON error somewhere which is breaking the execution, or b. it's not actually being called. To check you could put an alert() before the fnDraw() call, and see if that works. Also worth checking your JSON return with jsonlint.com, and looking for any JS errors.
2. Sorting not working - since you are using server-side processing, the sorting is done on the server-side. If the data is unsorted, then that would suggest an issue with your server-side script. Perhaps dump the SQL query and make sure it is what you expect.
Regards,
Allan
Thanks for your response! I'll be at home a little bit later tonight and I'll check it out. I know that the fnDraw is being called, there's an error there somewhere. When I get home from work I'll investigate it further and let you know what I come up with. Thanks again,
Kevin
oSort['string-ASC'] is not a function
jquery.dataTables.min.js Line 358
Ah - got it. Thanks for the debug trace. The issue is just that you have 'ASC' in the aaSorting initialiser rather than 'asc' :-). The associative arrays in Javascript are case sensitive, so if you just change the case it should work fine.
Regards,
Allan
I am sorry to revival this subject but i have the same problem.
My fnDraw() has not effect however i haven't error and my json tring is correct.
Here is my code :
[code]$(document).ready( function () {
$("#tab li").live('click', function (){
(...)
$.ajax({
"async": true,
"data": "&myTabulation="+$(".selectedTab a").html(),
"type": "POST",
"url": "json.php",
"success": function(data){
oTable.fnDraw();
}
}
}
var oTable = $('table.display').dataTable( {
"bFilter": false,
"bAutoWidth": false,
"bPaginate": false,
"bJQueryUI": true,
"bProcessing": true,
//"bServerSide": true,
"sAjaxSource": 'json.php',
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "myTabulation", "value": $(".selectedTab a").html() } );
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
} );
}[/code]
and the json string returned by json.php file :
[code]{"aaData":[[3,"test1",1],[2,"test2",1],[1,"test3,2]]}[/code]
Thanks a lot.
Jimmy
ps : Sorry for my english wich is not good...
Allan
I forgot to put [code]"bServerSide": true,[/code]
But now the colon sorting is not automatic... i must to make it with ajax request !
Allan
[code]
table = $('#listing_table').dataTable({
"bProcessing": true,
"bServiceSide": true,
"sAjaxSource": "orders/filter_listing"
});
$('#search_form').submit(function(e){
e.preventDefault();
alert('true');
table.fnDraw();
});
[/code]
With the above code, I'm not getting another call to the ajax source. My understanding from the above thread is that this should be causing another call to the server, but doesn't appear to be. Am I missing something obvious?
Thanks.
I am facing same issue, I have to fill datatable on change of dropdown list for that I am doing server process and getting data from there, after that I have to use fnDraw() to display the data and its working good in chrome and IE but in Firefox its not working. I need to refresh page manually to get data on grid.
Could you suggest any solution? any help would be highly appreciated.
Allan