Server side pagination using Spring MVC
Server side pagination using Spring MVC
Hi All,
I am currently working in a project that uses datatables where the values i retrieve from DB as the no. of records ranges to around 10k i want to use server side pagination. i had tried some but it is not working.
I am posting my script for your reference, please help me in figuring out my mistake. $(document).ready(function() {
$("#testststtsts").hide();
$("#reportsSearch").submit(function(e) { e.preventDefault(); var dataVal = $('#reportsSearch').serialize(); validation(); var csrf = document.getElementById("csrf").value; var csrfName = document.getElementById("csrf").getAttribute("name"); $.ajax({ url : 'ReportsSearchResults', data : dataVal,
context : document.body, type : 'post', dataType: 'json',
beforeSend: function(xhr) { xhr.setRequestHeader(csrfName, csrf); }, success: function (res) {
if (res != "[]") { var tableData = new Array(); tableData = res.data; $('#reportsResults').dataTable( { "processing": true, "serverSide": true, "ajax": { "url": "/ReportSearchResults", "type": "POST" }, "bJQueryUI": true, "aaData" : tableData, "aoColumns": [ { "mData": "userName"}, { "mData": "action"}, { "mData": "airlineCode" }, { "mData": "companyName" }, { "mData": "requestedDate" }, { "mData": "processedDate" }, { "mData": "days" }, { "mData": "status" }, { "mData": "profile" }, { "mData": "mrtUser" } ], });
} $("#testststtsts").show(); $('#reportsResults_length').hide(); $('#reportsResults_filter').hide(); }, error: function (data, errorThrown) { var resp = jQuery.parseJSON(data.responseText); var errorCount = resp.errorCount; var errors = resp.errors; for(var i=0;i<errorCount;i++) { var errorBean = errors[i]; alert('ErrorType'+errorBean.errorType); alert('ErrorCode'+errorBean.errorCode); alert('ObjectName'+errorBean.objectName); alert('DefaultMessage'+errorBean.defaultMessage); } } }); return false; });
$("#clear").click(function(){ $('#reportsResults').dataTable().hide(); $('#reportsResults_info').hide(); $('#reportsResults_previous').hide(); $('#reportsResults_next').hide(); $('#download').hide(); }); });
I am current using Spring MVC where the url in ajax refers to the value i had given in my @requestmapping annotation in controller.
Thanks,
Jafer
Answers
What do you mean? Error messages? Console info?
Also, please use Markdown to format your code sample.
Can you please provide me an example on how to use server side pagination using Spring MVC