The followings is the code for paginated datatable in my JSP:
$(document).ready( function() {
$('#paginatedTable').dataTable( {
"bServerSide" :true,
"sAjaxSource" :"/JQueryPagination/Myservlet",
"bProcessing" :false,
"sPaginationType" :"full_numbers",
"bJQueryUI" :false,
"aoColumns" : [ {
"mDataProp" :"Name"
}, {
"mDataProp" :"Address"
}, {
"mDataProp" :"Town"
} ]
});
});
In my servlet, I have a query that fetches the entire data from a database table, say company which returns me a million rows in the result set.
List<Company> companies = fetchCompleteCompanyDataFromDb();
This result set is then filtered as below:
List<Company>filteredCompanyList = companies.subList(iDisplayStart,DisplayStart+iDisplayLength);
The filteredCompanyList
is the list I'm displaying in the datatable, which is 10 rows.
When the user clicks the 'Next' button of the pagination, a new request is fired with will fetch the complete company data again and then the next 10 records for the second page is filtered. In short, whenever the user clicks the next button, a query for fetch a million record is fired.
I need to know whether is there a way where when the user clicks the next button, only the next 10 records to show will be fetched.