datatables custom http request

datatables custom http request

alfaomega83alfaomega83 Posts: 1Questions: 1Answers: 0

hi all,
i'm trying to implement server-side processing using a spring controller(like a servlet). my problem is when i try to send extra parameters to the servlet. Everything works fine but i can't use sorting or searching in the generated table.It appears that after the first ajax request the datatables stop calling my servlet when i change search parameters or ordering.....

javarscript code inside jsp :

        $(document).ready(function () {
            $("#prova").dataTable({             
                "bServerSide": true,
                "aLengthMenu": [[ 100 ], [ 100]],
                "iDisplayLength" : 100, 
                //"sAjaxSource": "./ritornaValoriTabella.do?codiDivi=${registroAnticipi.codiDiviAnti}&codiSett=${registroAnticipi.codiSettAnti}&SINSESSIONID=${SINSESSIONID}",                  
                "sAjaxSource":"./ritornaValoriTabella.do",
                "fnServerData":function (sSource, aoData, fnCallback) {
                    aoData.push({"name":"SINSESSIONID", "value":${SINSESSIONID} } ,
                    {"name":"codiDivi", "value":${registroAnticipi.codiDiviAnti}}  ,
                    {"name":"codiSett", "value":${registroAnticipi.codiSettAnti}}  );
                    $.getJSON( sSource, aoData, function(json) {
                        fnCallback(json)
                    });
                },
                "bProcessing": true,
                "sPaginationType": "full_numbers",
                "bJQueryUI": true,
                "oLanguage": {              

                    "sEmptyTable":     "Nessun dato presente nella tabella",
                    "sInfo":           "Vista da _START_ a _END_ di _TOTAL_ elementi",
                    "sInfoEmpty":      "Vista da 0 a 0 di 0 elementi",
                    "sInfoFiltered":   "(filtrati da _MAX_ elementi totali)",
                    "sInfoPostFix":    "",
                    "sInfoThousands":  ",",
                    "sLengthMenu":     "Visualizza _MENU_ elementi",
                    "sLoadingRecords": "Caricamento...",
                    "sProcessing":     "Elaborazione...",
                    "sSearch":         "Cerca:",
                    "sZeroRecords":    "La ricerca non ha portato alcun risultato.",
                    "sEmptyTable": " Nessun dato rinvenuto. ",
                    "oPaginate": {
                        "sFirst":      "Inizio",
                        "sPrevious":   "Precedente",
                        "sNext":       "Successivo",
                        "sLast":       "Fine"                   
                    },
                    "oAria": {
                        "sSortAscending":  ": attiva per ordinare la colonna in ordine crescente",
                        "sSortDescending": ": attiva per ordinare la colonna in ordine decrescente"
                    }
                },
                "aoColumnDefs": [ { "bSortable": false,"aTargets": ['nosort']} ],                           
            });
        });

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Can you link to a test case showing the problem, as per the forum rules.

    I don't immediately see any problem with the above code. It should always send the data address by fnServerData on each request since you have enabled server-side processing.

    Allan

This discussion has been closed.