All row displaying on initialisation
All row displaying on initialisation
briangal
Posts: 5Questions: 0Answers: 0
Hey,
I using an Ajax request to get the initial row and column data
I'm using sAjaxSource to do my server side processing.
I'm also using iDeferLoading as I only want my "sAjaxSource" to trigger for filtering / sorting etc
I've got 26 rows in total and displaying 5 with pagination enabled by default.
The issue i'm having is that all 26 rows are being displayed on initial load.
Interestingly I still get - Showing '1 to 5 of 26 entries' at the bottom of the table
iDeferLoading seems to be working ok getSubsetData does not get triggered
Commenting out "bServerSide": true and "sAjaxSource": "${request.contextPath}/table/getSubsetData" fixes the issue
Here's my code:
[code]
$(document).ready(function() {
$.ajax( {
"dataType": 'text',
"type": "GET",
"url": "${request.contextPath}/table/getTableData?tableType=basic",
"success": function (dataStr) {
var data = eval( '('+dataStr+')' );
$('#example').dataTable({
"aaData": data.aaData,
"aoColumns": data.aoColumns,
"iDisplayLength": 5,
"iDeferLoading": 26, //todo: 26 is total number of rows - needs to be dynamic
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "${request.contextPath}/table/getSubsetData"
});
}
} );
});
[/code]
I using an Ajax request to get the initial row and column data
I'm using sAjaxSource to do my server side processing.
I'm also using iDeferLoading as I only want my "sAjaxSource" to trigger for filtering / sorting etc
I've got 26 rows in total and displaying 5 with pagination enabled by default.
The issue i'm having is that all 26 rows are being displayed on initial load.
Interestingly I still get - Showing '1 to 5 of 26 entries' at the bottom of the table
iDeferLoading seems to be working ok getSubsetData does not get triggered
Commenting out "bServerSide": true and "sAjaxSource": "${request.contextPath}/table/getSubsetData" fixes the issue
Here's my code:
[code]
$(document).ready(function() {
$.ajax( {
"dataType": 'text',
"type": "GET",
"url": "${request.contextPath}/table/getTableData?tableType=basic",
"success": function (dataStr) {
var data = eval( '('+dataStr+')' );
$('#example').dataTable({
"aaData": data.aaData,
"aoColumns": data.aoColumns,
"iDisplayLength": 5,
"iDeferLoading": 26, //todo: 26 is total number of rows - needs to be dynamic
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "${request.contextPath}/table/getSubsetData"
});
}
} );
});
[/code]
This discussion has been closed.
Replies
With 26 rows only, you'd be as well just using the data loaded from the DOM I would say. Server-side processing only really becomes interesting when you are dealing with many thousands or millions of rows.
Allan
Using this data I wanted to initialize the table i.e.
[code]
"aaData": data.aaData,
"aoColumns": data.aoColumns,
[/code]
This works fine, even with "iDeferLoading" set.
The only HTML I'm using is:
[code]
[/code]
When I include the following
[code]
"bServerSide": true,
"sAjaxSource": "${request.contextPath}/table/getSubsetData"
[/code]
I then get the pagination issue described above.
The 26 rows is just test data, potentially we have thousands of rows to deal with.
hope this makes sense....
Allan
Ye, its 26. I understand what i need to do now, thanks. The processing of the rows needs to be done on initialization when using serverSide and ajaxSource and not just when filtering, sorting etc.