Simulating an ajax call for deferred loading

Simulating an ajax call for deferred loading

mak1mak1 Posts: 25Questions: 13Answers: 1

I'm using datatables 1.10 w/ Scroller plugin with Chrome and Win7.

Below is my initialization for the datatable. There are certain scenarios where we get about 150K records from the server to load. Since we load the data all at once, datatable hogs a lot of memory and sometimes even crashes the browser.

I understand that using server-side = true and ajax you can load as you scroll instead of loading all the data at once.

We currently don't have the capability of changing much from the server side. So what I want to know is if I can simulate an ajax call for deferred loading and even deferred rendering purposes? I currently store all the records in a javascript array of objects( let's call it X) which loads without errors but hogs a lot of memory and is super slow.

So is there a way as the user scrolls down the table that instead of calling the server, datatables calls some function that would grab the next chunk of data from X the client side object?

Any example code would be appreciated.

var xDataTable= $('#x_table').DataTable( {
        rowId: 'rowId',
 dom: 'Bfrtip',
    buttons: [
        'copy', 'csv', 'excel', 'pdf', 'print'
    ],

"deferLoading": 20,

           processing: true,

 deferRender:    true,
        scrollY:        300,
       // scrollCollapse: true,
           scroller: true,
     scrollX: true ,
     lengthChange: false,
    select: {
        style: 'single'
    },
columns: [
    { data: 'X',title: 'X-label', defaultContent: "" },

........20 columns.....
]
} );

This discussion has been closed.