iDisplaylength not limiting records.
iDisplaylength not limiting records.
kmorris
Posts: 0Questions: 0Answers: 0
I'm using version 1.9.0 datatables with verison 2.0.0 of Tabletools to do an ajax call to retrieve records from my database.
with iDisplaylength set to 25, it is still displaying the entire result set of 5000+ records.
Is there an issue using Datatables/TableTools with Ajax calls as it pertains to iDisplaylength?
oTable = $("#example").dataTable({
"sDom": \'T<"clear">lfrtip\',
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [ "select_all", "select_none" ]
},
"oLanguage": {
"sEmptyTable": "There are no records that meet the criterial"
},
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"sAjaxSource": "/mypath/ajax/get_myrecords.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "name": "area", "value": "1234" } );
aoData.push( { "name": "emailtype", "value": $("#emailtype").val() } );
$.getJSON( sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
} );
},
"iDisplayLength": 25,
"sPaginationType": "full_numbers",
"aaSorting": [[0, "desc"]],
"bStateSave": true
});
Thanks in advance!
Kevin
with iDisplaylength set to 25, it is still displaying the entire result set of 5000+ records.
Is there an issue using Datatables/TableTools with Ajax calls as it pertains to iDisplaylength?
oTable = $("#example").dataTable({
"sDom": \'T<"clear">lfrtip\',
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [ "select_all", "select_none" ]
},
"oLanguage": {
"sEmptyTable": "There are no records that meet the criterial"
},
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"sAjaxSource": "/mypath/ajax/get_myrecords.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "name": "area", "value": "1234" } );
aoData.push( { "name": "emailtype", "value": $("#emailtype").val() } );
$.getJSON( sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
} );
},
"iDisplayLength": 25,
"sPaginationType": "full_numbers",
"aaSorting": [[0, "desc"]],
"bStateSave": true
});
Thanks in advance!
Kevin
This discussion has been closed.
Replies
In my set up it this adjustment is 3rd statement in the protected get_paging function at approx line 209 in the Datatables.php library file (native-php-version of server side php file). Essentially, I am doing pseudopipelining--grabbing about 200 records at a time and then letting the datatables.js features handle sorting and pagination on the client side. For different query, it requires another XHR call and this again sets a 200 XHR generated subset which is then processed in smaller chunks at client. This is a bit of a hack, but it works well as a tradeoff between server and client processing. Possibly n1crack or Allan can figure out why the iDisplayLength is not being recognized by the server side script as expected to override the maximum records retrieved from the mysql database when used in this fashion. I'm still tweaking, will let you know if I figure it out. Cheers and thanks to the production team!
Allan
http://flightphysical.com/aaplain.php
We have currently solved this with Pedro Alves fnLengthChange plugin which you host and post here: http://datatables.net/plug-ins/api and that function is working great with yours. Thanks again for this sweet code. I have donated in past and will continue to do so (or hire out some work) as our project evolves. Much gratitude!
-J.O.
That should be an integer not a string, is the first thing that stands out to me. The second is that it would appear that there are only 25 rows in the database and all of them are loaded. Thirdly you aren't using server-side processing here (nor, I think, do you need to with so few rows - you should only need server-side processing with 50'000+ rows).
Allan
We tried iDisplayLength alternatively as string and integer (it is back to integer), and that along with the fnLengthChange seems to have resolved unexpected results, not sure if this helps OP's issue. We can confirm and did notice the first extracted subsets were being capped initially prior to the fnLengthChange plugin (eg, iDisplayLength parameter being ignored), but the combination of the fnLengthChange plugin and switching type back to int seems to have resolved the issue.
If I can reproduce original issue more accurately, I will try to be more helpful and nail it down, meanwhile thanks for the reply and advice.
Allan