Initializing dataTables with no records to display at first

Initializing dataTables with no records to display at first

angiemanilaangiemanila Posts: 1Questions: 0Answers: 0
edited September 2011 in General
I have the following to initialize my dataTable:
[code]
jQuery(document).ready(function(){
...
var oTable = jQuery("#" + nameSpace + "portletsTable").dataTable( {
"sPaginationType": "full_numbers",
"aLengthMenu": [[25, 50, 75, 100], [25, 50, 75, 100]],
"iDisplayLength": 25,
"bAutoWidth": false,
"bFilter": false,
"bServerSide": true,
"fnDrawCallback": function() {
afterRedraw();
},
"fnPreDrawCallback": function() {
beforeRedraw(nameSpace);
}
});
}
[/code]

and the following which is executed several times (every after search is made):
[code]
function reloadDataTable (portletNameSpace, form, columnNames) {
var nameSpace = (portletNameSpace == undefined ? "" : portletNameSpace);
var dataString = form.serialize();
var oTable = jQuery("#" + nameSpace + "portletsTable").dataTable({"bRetrieve": true});
var url = form.attr('action') + '&p_p_resource_id=find&' + dataString + '&sortColumnNames=' + columnNames.toString();

oTable.dataTableSettings[0].aaSorting = [ [0, 'asc', 0] ]; //reset to default sorting
oTable.dataTableSettings[0].sAjaxSource = url;
oTable.fnDraw();
}
[/code]

My problem is how do I define my sAjaxSource without having any data to display during initialization and without making it "null"?
If I don't specify my sAjaxSource during initialization, I will have the following log on console:
[code]
[PortalImpl] Current URL /web/guest/null?sEcho=1&iColumns=15&sColumns=&iDisplayStart=0&iDisplayLength= ... &_=1316658583632 generates exception: null
[/code]
I know for a fact that bServerSide must be used together with sAjaxSource.
Thank you very much!

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    http://www.datatables.net/ref#iDeferLoading
This discussion has been closed.