DataTables 1.10.9 still error: (Cannot read property 'oScroll' of undefined) if more than one Table

DataTables 1.10.9 still error: (Cannot read property 'oScroll' of undefined) if more than one Table

phawellphawell Posts: 28Questions: 12Answers: 1

With that version of datatable if create more than one datatable in diferents tabs We notice that last datatable in the last tab do not present any problem but all previos datetables start to launch this Js error in the chrome console :

Cannot read property 'oScroll' of undefined

But this error only show every time we resize the width of a column because we use in this tables the colResize JS (dataTables.colResize.js)

Every time we resize a colum ad a new error in chrome inpector

Must I set some property for scroll for avoid this error? We use always the pagination with numbers

Thanks in advance

This question has an accepted answers - jump to answer

Answers

  • phawellphawell Posts: 28Questions: 12Answers: 1
    edited January 2016

    We found out more clues.

    The line of the problem is in this library:
    jquery.dataTable.js

    The line is this:
    var scroll = settings.oScroll;

    And it is inside this function:

    ..............................................................................

    this.fnAdjustColumnSizing = function ( bRedraw )
    var api = this.api( true ).columns.adjust();
    var settings = api.settings()[0];
    var scroll = settings.oScroll;
    if ( bRedraw === undefined || bRedraw )
    api.draw( false );

    else if ( scroll.sX !== "" || scroll.sY !== "" )
    /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
    _fnScrollDraw( settings );

    .............................................................................

    Maybe if We initialize some property We could deactivate this function?
    I hope it's something very simple to control, but We can't find out how.

    What if we canceled that line at the jquery.dataTable.js library??

    Thanks in advance.

  • allanallan Posts: 61,916Questions: 1Answers: 10,150 Site admin

    Sounds like an issue with dataTables.colResize.js (I'm not familiar with that library so I can't really say - where is it from?).

    Allan

  • phawellphawell Posts: 28Questions: 12Answers: 1
    edited January 2016

    Thank you for your help. We'll try to controll that error in the especific function in datatable js.

    If We check scroller object it can work so the scroller musn't be iundefined. But only a simple and provisional fix.

  • phawellphawell Posts: 28Questions: 12Answers: 1

    This is for other Who get this error and I now this is not a very elegant solution but in the meantime my solution is this but at least not give the error code and incidentally is more shielded

    In the dataTables.colResize.js file just in the line where it try to use that objet and launch the error because it is undefined simply We check this posibilities.

    This is my change see the previos code sended yesterday
    ..................................................................

            this.fnAdjustColumnSizing = function ( bRedraw )
    
                var api = this.api( true ).columns.adjust();
                var settings = api.settings()[0];
                var scroll=null;
    
                if(typeof settings !== 'undefined' && typeof settings.oScroll !== 'undefined')
                    scroll = settings.oScroll;
    
                if ( bRedraw === undefined || bRedraw ) 
                        api.draw( false );
    
                else if ( scroll != null && (scroll.sX !== "" || scroll.sY !== "") ) 
                        /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
                        _fnScrollDraw( settings );
    

    ................................................................................

            };
    
  • allanallan Posts: 61,916Questions: 1Answers: 10,150 Site admin
    Answer ✓

    Thanks for posting back with your fix.

    Allan

  • ConstantineConstantine Posts: 1Questions: 0Answers: 0

    Why don't this patch applied to actual codebase? I'm tired to apply it again and again

  • allanallan Posts: 61,916Questions: 1Answers: 10,150 Site admin

    Because, as far as I understand it, its an error in the third party column resizing library and should be addressed there.

    Allan

This discussion has been closed.