DWR and Datatables

DWR and Datatables

ayusunayusun Posts: 4Questions: 1Answers: 0

I was following this topic http://www.datatables.net/forums/discussion/6562/dwr-and-datatable to make the integration between datatable and dwr work, but it doesn't work.

My requirement is i have to use dwr and I also have to use pagination(lazy loading or server side processing) but I am kind of stuck. Here is my code

var dataTable = $('#logTable').DataTable({
        "bFilter":false,
        //"bLengthChange": false,
        "fnServerData" : getLogs,
        "bServerSide" : true,
        "processing" : true,
        "fnServerData" : function ( sSource, aoData, fnCallback, oSettings ) {
              App.getLogs(some_parameter,{
                async:false,
                callback:function(result){
                    oSettings._iRecordsTotal = result.iTotalRecords;
                    oSettings._iDisplayLength = result.iTotalDisplayRecords;
                    console.log(oSettings);

                //oSettings = result;
                //console.log(result);
                    if(result.aaData.length > 0){
                        $.each(result.aaData, function(){
                            var newRow = $("tr");
                            $("<tr><td>" + this.createDate.toLocaleString() + "</td><td>" + (Date.parse(this.createDate) - Date.parse(this.endDate)) + "</td><td>" + this.apiName + "</td><td>" + this.execStatus + "</td><td style='text-overflow:ellipsis;width:100px;display:block;overflow:hidden;white-space:nowrap;'>" + this.inputXml + "</td><td>" + this.serverUrl + "</td><td><input type='button' value='details'></input></td></tr>").appendTo($("#logTable > tbody"));
                        });
                    }
                }});

        }
});

I never get the page numbers this way. I was hoping to send the new record number in the place of some parameter and would get the result this way, however that's the thing of the future. Any idea how to make it working using dwr?

P.S : I get All the results, it just doesn't paginate and consider about the solution from the lazy loading perspective

Thanks

Answers

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    fnServerData is a legacy API. I would suggest using ajax and updating your code to use the new server-side processing parameters.

    Allan

  • ayusunayusun Posts: 4Questions: 1Answers: 0

    Thank you for the comment. I would really like if you can open this thread for a while longer as I may need your assistance on this

  • ayusunayusun Posts: 4Questions: 1Answers: 0

    Ok, if I understand it correctly, i will have to use

    function (data, callback, settings) {
     //my ajax function
    

    }

    So, the next question is, if i am going to use

    App.getLogs(some_parameter,{})

    Now, there are some parameters(my own parameters) which i am sending, so should i send all those parameters that datatable uses here only. And do i need to send all the parameters, i just want pagination and serverside only(no searching or sorting features).

    And one more doubt, the json that i return. where should it be assigned to as in my case, the json is in result variable. WHat should i do with it?

    App.getLogs(some_parameter,{
                async:false,
                callback:function(result){
                     console.log(result);
    
                    }
       }});
    
  • ayusunayusun Posts: 4Questions: 1Answers: 0

    Ok, I should call callback after i get the data. Ok will post it here, if I came into some kind of problem. Please watch this thread.
    Thanks

This discussion has been closed.