无法使用Scroller Extension jQuery Datatable加载服务器端数据

时间:2017-09-04 07:19:40

标签: javascript jquery ajax datatables salesforce

我正在尝试使用Scroller插件渲染我的Datatable。数据加载一次,但滚动时进一步显示只加载数据。我错过了什么吗?我正在尝试在Salesforce Lightning中实现它。我已经加载了Scroller Library v1.4.2和DataTable v1.10.11

sessionTable = $j('#table-1').DataTable(
 {
 "info": true,
 "searching": true,

 "processing": false,
 "dom": '<"div-pg"pi><"div-search"f><"div-tbl">t<"bottom-info"> ', // f search, p :- pagination , l:- page length
  paging:true,
 "order" : [[2,"asc"]],
 "serverSide": true,

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


              allRecs.setParams(
              {
                 "request" : data ,
              });

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

                    var state = response.getState();

                     if(state === 'SUCCESS' && response.getReturnValue != null)
                     {
                         //callback(JSON.parse(response.getReturnValue()));
                        //callback(sessionTable.rows.add(JSON.parse(response.getReturnValue())).columns.adjust().draw());

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

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



                 });
                 $A.enqueueAction(allRecs);
     },


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

 "language":
 {
     "emptyTable": "Loading Data"
 },

1 个答案:

答案 0 :(得分:0)

问题在于Salesforce Lightning,它没有返回响应。 以下是对此的解释,我们可以通过在排队后添加以下代码来强制Salesforce提供响应: -

function(print_target_properties tgt)
    if(NOT TARGET ${tgt})
        message("There is no target named '${tgt}'")
        return()
    endif()

    # this list of properties can be extended as needed
    set(CMAKE_PROPERTY_LIST SOURCE_DIR BINARY_DIR COMPILE_DEFINITIONS
             COMPILE_OPTIONS INCLUDE_DIRECTORIES LINK_LIBRARIES)

    message("Configuration for target ${tgt}")

    foreach (prop ${CMAKE_PROPERTY_LIST})
        get_property(propval TARGET ${tgt} PROPERTY ${prop} SET)
        if (propval)
            get_target_property(propval ${tgt} ${prop})
            message (STATUS "${prop} = ${propval}")
        endif()
    endforeach(prop)

endfunction(print_target_properties)