I am trying to render my Datatable with Scroller plugin in. Data is loading once but when scrolled further shows loading data only. Am I missing something ? I am trying to implement it in Salesforce Lightning

     sessionTable = $j('#table-1').DataTable(
 "info": true,
 "searching": true,
// destroy : true,
 "processing": false,
 "dom": '<"div-pg"pi><"div-search"f><"div-tbl">t<"bottom-info"> ', // f search, p :- pagination , l:- page length
 //"data": '',
 "order" : [[2,"asc"]],
 "serverSide": true,

 //scrollY: "200px",
 scrollX : true,
 "ajax": function (data, callback, settings) {
              var allRecs = component.get("c.runQuery");

             console.log('Here in AJAX');
                 "request" : data ,

                 allRecs.setCallback(this, function(response)
                    console.log('in setCallback Populating Data' );

                    var state = response.getState();

                     if(state === 'SUCCESS' && response.getReturnValue != null)

                         var resp = JSON.parse(response.getReturnValue());

                         setTimeout( function () {
                         callback( {
                             data: JSON.parse(resp.data),
                             recordsTotal: resp.recordsTotal,
                             recordsFiltered: resp.recordsTotal
                         } );
                              }, 200 );


 scrollY:     "300px",
 scroller: {
     loadingIndicator: true
 scrollCollapse: true,

     "emptyTable": "Loading Data"
  • have you tried any debugging at all? stating a description of your problem and dumping your code is not really the best approach for getting help. Additionally, if you are developing in lightning, there are several architectural considerations you should be aware about -> Locker service. Take some time to review How to Ask and take the tour to get familiar with the forum, thanks! – glls Sep 4 '17 at 13:17
  • May i know what you found wrong in this question ? I have been trying to work on the issue from past 2 days. Did lot of debugging. Locker service supports the version of jQuery and Datatable I am using. – sahildcoder Sep 4 '17 at 19:44
  • for starters, you did not include any debugging details in your post – glls Sep 4 '17 at 19:51
  • Debugging Details :- As soon as i scroll down AJAX Should be called which is getting called there is no callback from APEX Controller. – sahildcoder Sep 14 '17 at 11:39

The issue was with Salesforce Lightning, it was not returning the response. Here is walkaround for this, we can force Salesforce to give response by adding following code after enqueuing:-

$A.getCallback(function() {
}), 200);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.