tapsboy
tapsboy

Reputation: 194

jQuery DataTables staggered loading

I am looking to load a large dataset from server into the jQuery DataTables (thousands of rows with about 20 to 30 columns)

Instead of loading the entire data on one go, I would like to load the table chunk by chunk. Make an ajax call fetch back a few hundred rows and repeat, when the user scrolls down. Something like feeds on facebook and twitter. You scroll down, more ajax calls are fired and more data comes to the browser DOM and gets rendered.

I am exploring various options. One was I thought was using fnAddData() API as well as iDeferLoading. Has anyone done this before or has any other pointers that I can look up?

Upvotes: 1

Views: 2302

Answers (1)

Jovan MSFT
Jovan MSFT

Reputation: 14610

Use server side processing where JQuery DatraTables send new ajax requests for each new page. Maybe you can also use infinite scrolling. Configuration shoudl look like:

$('#example').dataTable( {
    "bServerSide": true,
    "sAjaxSource": "../server_side/scripts/server_processing.php"
    sScorollX: "300px", 
    sScrollY: "200px"
    bScrollInfinite:true //this property disables pagination
} );

You can find more details on the DataTables site.

Jovan

Upvotes: 2

Related Questions