iDeferLoading & paging

iDeferLoading & paging

mcbutterbunsmcbutterbuns Posts: 7Questions: 0Answers: 0
edited June 2011 in DataTables 1.8
Hello,

I've enabled iDeferLoading (what a wonderful new feature) on my table. However, I'm also employing pipelining to load 150 records spanned over 3 pages (page size of 50).

When I render the table, I print out my 150 records and have iDeferLoading turned on. Instead of taking the 150 records and pushing them into 3 pages, the first page is 150 records long.

Is there anyway to have datatables respect the page size with an initial dataset larger than the initial page?

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Are you setting iDisplayLength in the initialisation: http://datatables.net/ref#iDisplayLength ? I haven't tried pipelining with iDeferLoading myself, so I can't say with any certainty that it will work, but DataTables should always respect iDisplayLength.

    Allan
  • mcbutterbunsmcbutterbuns Posts: 7Questions: 0Answers: 0
    Yes I am specifying iDisplayLength. The value in the config is set to 50. I'm going to check my code again just to be sure that it isn't something dumb that I'm overlooking.
  • mcbutterbunsmcbutterbuns Posts: 7Questions: 0Answers: 0
    Here is my config as well. I've removed some of the "aoColumns" values since there were 12 redundant values in it.

    If there's not a solution at this time, I can easily work around it but just curious if there was anything I may be missing.

    [code]
    $('#table').dataTable({
    "bJQueryUI": true,
    "aoColumns": [
    {
    "bSearchable": false,
    "bSortable": false,
    "bVisible": true,
    "sType": "html"
    }
    ],
    "aaSorting": [
    [
    3,
    "desc"
    ]
    ],
    "iDeferLoading": 2905,
    "bSort": true,
    "bPaginate": true,
    "sPaginationType": "full_numbers",
    "bInfo": true,
    "bFilter": false,
    "bAutoWidth": false,
    "iDisplayLength": 50,
    "bLengthChange": true,
    "aLengthMenu": [
    25,
    50,
    100,
    250
    ],
    "bStateSave": false,
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "/path/to/data",
    "oLanguage": {

    },
    "fnRowCallback": rowCallback,
    "fnServerData": function(sSource,aoData,fnCallback){
    fnDataTablesPipeline(sSource, aoData, fnCallback, 3);
    },
    asSorting: [

    ]
    });
    [/code]
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Ah - I think I've got it - it didn't quite compute when I read your post originally:

    [quote]When I render the table, I print out my 150 records and have iDeferLoading turned on. Instead of taking the 150 records and pushing them into 3 pages, the first page is 150 records long.[/quote]

    What iDeferLoading makes DataTables do is basically leave whatever you have in the table alone when DataTables would normally do its first draw. So you've got 150 records and DataTables just leaves them as they are - it won't try to do a proper "draw" with them, which would be required for the paging to work as expected.

    So there are two options which spring to mind:

    1. Simply display only the first page of 50 in the HTML (which was what I had been expecting the use of this feature would entail)

    2. Use Javascript to remove rows 51+ just before you initialise your DataTable. This way it will keep 150 rows for non-JS users, and paging will work as expected for JS users.

    Allan
  • mcbutterbunsmcbutterbuns Posts: 7Questions: 0Answers: 0
    Haha yeah, its Monday and even I had a little trouble understanding what I wrote.

    Thanks for your help. I think I'll just show the initial 50 records and let subsequent paging do the rest of the dirty work.

    Since the table will show the most recent data, user's wont be paging beyond the first page for most of the time so this will still reduce the number of round trips.

    Thanks again!
This discussion has been closed.