SCRIPT5007: Unable to get value of the property 'style': object is null or undefined (on destroy)

SCRIPT5007: Unable to get value of the property 'style': object is null or undefined (on destroy)

murali_kmdmurali_kmd Posts: 3Questions: 1Answers: 0
edited November 2016 in Free community support

I'm using jQuery DataTables 1.10.7

On table destroy, I'm getting the following error.
SCRIPT5007: Unable to get value of the property 'style': object is null or undefined

The root cause is, at the method _fnCalculateColumnWidths (oSettings), the below lines are causing the issue. The headerCells are having lesser elements than visibleColumns. In my case, the visibleColumns are having array of 8 elements, where as the headerCells are having only 5 elements.

My data grid is having 2 hidden columns, but those columns are also retrieved in visibleColumns while destroying, but the headerCells are only having the actual visible columns. That is causing this issue below, please suggest what is the solution.

                    visibleColumns = _fnGetColumns( oSettings, 'bVisible' )
        // Apply custom sizing to the cloned header
        headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );

        for ( i=0 ; i<visibleColumns.length ; i++ ) {
            column = columns[ visibleColumns[i] ];
            headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
                _fnStringToCss( column.sWidthOrig ) :
                '';
        }

Answers

  • allanallan Posts: 63,836Questions: 1Answers: 10,518 Site admin

    It should be making the columns visible prior to that.

    Could you give me a link to the page showing the issue, or a link to a test case showing it, so I can help to debug and fix the issue please.

    Allan

  • murali_kmdmurali_kmd Posts: 3Questions: 1Answers: 0
    edited November 2016

    This page is internal application, don't have it www site.

    The test is very simple and straight, generate the datatable vertical scrollable with 6 columns.

    $('#queueTaskSummaryGridId').DataTable().column(2).visible( false );
    $('#queueTaskSummaryGridId').DataTable().column(3).visible( false );

    and then again make it true.

    $('#queueTaskSummaryGridId').DataTable().column(2).visible( true );
    $('#queueTaskSummaryGridId').DataTable().column(3).visible( true );

    It breaks and shows the above error.

  • murali_kmdmurali_kmd Posts: 3Questions: 1Answers: 0
    edited November 2016

    I have found the work-around. By providing the 2nd parameter for visible as "false" avoiding the redraw the column which solves the issue.

    $('#queueTaskSummaryGridId').DataTable().column(2).visible(true, false);

    I'm good, this issue can be closed.

  • allanallan Posts: 63,836Questions: 1Answers: 10,518 Site admin

    I've just tried running that and it appears to work as expected: http://live.datatables.net/gasoxini/1/edit .

    Are you able to modify that to make it match how you were using it?

    Thanks,
    Allan

  • s.jacqs.jacq Posts: 15Questions: 3Answers: 3
    edited January 2017

    I had the same issue with columns set with visible=false during the destroy process.

    I solved it by replacing visible=false by className="hidden" in the column def.

    Then the column is not retrieved in the visibleColumns and the lengths of the arrays match.

    Rgds

This discussion has been closed.