defer data load

defer data load

hawkhawk Posts: 1Questions: 0Answers: 0
edited May 2011 in General
Hi,

I would like to ask one question, how to defer loading of data? the requirement is that firstly the data table is empty and no data in there, after user fill in the searching criteria and click the search button, the result will be returned from server side and populate into the table.

1. Init the empty table

[code]
var oTable=$('#userListTable').dataTable({
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true
});
[/code]

2. Click on search button, populate data

[code]
$('#searchButton').click(function() {
//what code should be put down here to init the ajax reqeust?
oTable.fnDraw();
});
[/code]

thanks in advance
hawk

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    In DataTables 1.8 (currently in beta) it is as easy as "iDeferLoading": 0 (see http://datatables.net/beta/1.8/examples/server_side/defer_loading.html for a live example).

    That will cause DataTables to read the initial data from the DOM (if there is any), and allow Ajax loading at a later time. Note that this only works with server-side processing though. If you are just wanting to use an Ajax source, then I'd suggest using $.ajax() and the DataTables API function fnAddData to first get your data and then load it into the table.

    Allan
This discussion has been closed.