Upgrade to datatables 1.10.12 breaks serverside processing with deferLoading

Upgrade to datatables 1.10.12 breaks serverside processing with deferLoading

kunal.bohrakunal.bohra Posts: 2Questions: 1Answers: 0

First of all, thank you for the great work. Recently upgraded to 1.10.12 and we are having problems with tables where serverSide and deferLoading is true. Prior to the upgrade(we were using 1.10.5) , our initialization as shown below worked without any issues

var eftTable = $('#search-list').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "/ajax.do?req.objectID=" + reqObjID + "&param.rtype=search",
"type": "GET"
},

            "language": {
                "info": "RECORDS _START_-_END_ OF _TOTAL_",
                "zeroRecords": " ",
                "infoEmpty": " "                    
            },
            "deferRender": true,
            "deferLoading": 0,
            "dom": "frtiS",
            "sScrollY": "310px",
            "scrollCollapse": true,
            "oScroller": {
              "rowHeight": "30"
            },
            "autoWidth": false,
            "bFilter": false,
            "columnDefs": [
            {
                "render": function ( data, type, row ) {
                return jopFunctions.formatCurrency(data);
                },
                "targets": 5 //paid amount
                }
            ],
            "columns": [
                { 
                    "data": "a",
                    'mRender': function(data) { 
                        return '<div  title="' + data + '">' + data + '</div>';
                    }                                                   
                },
                {
                    'orderable': true, 
                    'data': 'b',    //batchId
                    'render': function(data){
                        return data != '0' ? data : '';
                    }
                },                  
                { 
                  "mData": "c" ,
                  "mRender": function (data, type, row) {
                    return jopFunctions.formatDate(data,"MM/DD/YYYY");
                    }
                },
                { "data": "d" },
                { "data": "e" },
                { "data": "f" },
                { "data": "g" },
                {
                    'orderable': false, 
                    'mData': 'null',
                    'mRender': function (data) {
                        return '<a href="#" class="search-detail"><span class="fa fa-file-text-o"></span></a>';
                    }
                },
                { 
                    'orderable': false, 
                    'mData': 'null',
                    'mRender': function (data) {
                        return '<a href="#" class="seach-image"><span class="fa fa-file-image-o">';
                    }
                },
                {
                    'orderable': false, 
                    'mData': 'null',
                    'mRender': function (data) {
                        return ' ';
                    }
                }
            ],
            "createdRow": function( row, data, dataIndex ) {
                $(row).attr( 'row-id', data.id );
            },
            "preDrawCallback": function(settings){

            },
            "drawCallback": function(settings) {

            }
        });

what this does(at least from what I understand anyway) is not make that initial call to populate the table. But since the upgrade, we are noticing that an ajax call is made regardless of deferLoading being set .
I noticed that in _fnInitalise, at first deferLoading is true(since bDeferLoading is true), but _fnDraw updates bDeferLoading to false,
so when deferLoading is checked in the condition(if dataSrc !== 'ssp' || deferLoading), deferLoading is still true , even though settings.bDeferLoading was set to false in _fnDraw, is this on purpose? or should the code check
if(dataSrc !== 'ssp' || settings.bDeferLoading), to decide if an ajax request should be built? or am I not using deferLoading like it's intended to be used?
function _fnInitialise ( settings )
{
var i, iLen, iAjaxStart=settings.iInitDisplayStart;
var columns = settings.aoColumns, column;
var features = settings.oFeatures;
var deferLoading = settings.bDeferLoading; // value modified by the draw

    /* Ensure that the table data is fully initialised */
    if ( ! settings.bInitialised ) {
        setTimeout( function(){ _fnInitialise( settings ); }, 200 );
        return;
    }

    /* Show the display HTML options */
    _fnAddOptionsHtml( settings );

    /* Build and draw the header / footer for the table */
    _fnBuildHead( settings );
    _fnDrawHead( settings, settings.aoHeader );
    _fnDrawHead( settings, settings.aoFooter );

    /* Okay to show that something is going on now */
    _fnProcessingDisplay( settings, true );

    /* Calculate sizes for columns */
    if ( features.bAutoWidth ) {
        _fnCalculateColumnWidths( settings );
    }

    for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
        column = columns[i];

        if ( column.sWidth ) {
            column.nTh.style.width = _fnStringToCss( column.sWidth );
        }
    }

    _fnCallbackFire( settings, null, 'preInit', [settings] );

    // If there is default sorting required - let's do it. The sort function
    // will do the drawing for us. Otherwise we draw the table regardless of the
    // Ajax source - this allows the table to look initialised for Ajax sourcing
    // data (show 'loading' message possibly)
    _fnReDraw( settings );

    // Server-side processing init complete is done by _fnAjaxUpdateDraw
    var dataSrc = _fnDataSource( settings );
    if ( dataSrc != 'ssp' || deferLoading ) {
        // if there is an ajax source load the data
        if ( dataSrc == 'ajax' ) {
            _fnBuildAjax( settings, [], function(json) {
                var aData = _fnAjaxDataSrc( settings, json );

                // Got the data - add it to the table
                for ( i=0 ; i<aData.length ; i++ ) {
                    _fnAddData( settings, aData[i] );
                }

                // Reset the init display for cookie saving. We've already done
                // a filter, and therefore cleared it before. So we need to make
                // it appear 'fresh'
                settings.iInitDisplayStart = iAjaxStart;

                _fnReDraw( settings );

                _fnProcessingDisplay( settings, false );
                _fnInitComplete( settings, json );
            }, settings );
        }
        else {
            _fnProcessingDisplay( settings, false );
            _fnInitComplete( settings );
        }
    }
}

Answers

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    It appears to be working okay in this example. There is an Ajax request, but that's to show the server-side processing script.

    Could you link to a page showing the issue so I can try to debug it please?

    Allan

This discussion has been closed.