3

I was trying to use jquery data tables with infinite scrolling to display the data in my server. I have a large collection of data in server, which is not fixed (number of records increase everyday, so there is no fixed number on how much data is present). I am trying to show it in twitter style pagination instead of normal pagenumbered google style pagination. My code looks like below. With this code I am able to load initial data. But I could not find any resource on how a second call can be triggered when the scroller reaches the end of current table and append new result to same table. Is there any function that dataTables provide to detecct the scroll end. Or do we have to write a scroll event and detect whether the scroller has reached the end of the table?

var table = $("#events-table").dataTable({
      "bProcessing": true,
         "bServerSide": true,
         "sScrollY": 100,
          "aoColumns": [
                    { "sTitle": "col1" },
                    { "sTitle": "col2" }
                ]
           "fnServerData": function (sSource, aoData, fnCallback) {
            $.ajax({
                url : “http://linkToAccessServer” + pagenumber,
                type : 'post',
                success : function(data){
                    var tableData = {};
                          tableData.iTotalRecords =  data.totaldata;
                          tableData.aaData = [];
          for(var i = 0; i < data.data.length; i++){
              var tableInnerArray = [];
              tableInnerArray.push(data.data.col1);
            tableInnerArray.push(data.data.col2);
              tableData.aaData.push(tableInnerArray);
          }
            fnCallback(tableData);
        }
        });


      }
  });
user1371896
  • 2,192
  • 7
  • 23
  • 32

0 Answers0