Processing data not draw on Server Side

Processing data not draw on Server Side

megc89megc89 Posts: 3Questions: 2Answers: 0

Hi guys, I am using DataTable Server-Side processing, and I am having problems when data should draw on data table.

this is my init .

$(document).ready( function () {
  var tableNomina  = $("#tabla-nomina").DataTable({
                processing: true,
                serverSide: true,
                ajax: {
                    url: "rest/search",
                    contentType: "application/json",
                    type: "POST",
                    data: function ( d ) {
                        var currentPage = 1;
                        
                        if(tableNomina != null){
                            var info = tableNomina.page.info();
                            currentPage = info.page;
                            console.log('currentPage: ' + info.page);
                        }

                        var postData = '{';
                        postData += '"nomina": "",';
                        postData += '"usuario": "",';
                        postData += '"fecha": "",';
                        postData += '"monto": "",';
                        postData += '"conceptoNid": -1,';
                        postData += '"origenNid": -1,';
                        postData += '"estadoNid": -1,';
                        postData += '"orderBy": "dfecnomina",';
                        postData += '"orderType": "ASC",';
                        postData += '"paginaActual": ' + currentPage + ',';
                        postData += '"registrosTotales": 1,';
                        postData += '"registrosFiltrados": 1';
                        postData += '}';

                        return postData;
                    },
                    dataSrc: 'data',
                    dataFilter: function(data){
                        console.log(data);
                        return data;
                    },error: function(error) {
                         console.log(error);
                    }
                }
                ,"columns": [
                    { data: 'nidnomina' },
                    { data: 'sidarchivo' },
                    { data: 'sestado' },
                    { data: 'sidusuarionomina' },
                    { data: 'dfecnomina' },
                    { data: 'nmontototalpagado' },
                    { data: 'sconcepto' },
                    { data: 'sidorigen' },
                    { data: 'nidnomina' }
                ]
            });
} );

When I get data from first and last page, this is OK, but when I get data from intermediate pages is the problem, data not render correcty.

My json returned from server is correctly valid, and containts the same struct from all requests,



Thanks

Answers

This discussion has been closed.