SCRIPT87: Invalid argument. error with FixedColumns and IE7/8

SCRIPT87: Invalid argument. error with FixedColumns and IE7/8

greenflashgreenflash Posts: 58Questions: 5Answers: 0
edited October 2011 in General
I get the error

SCRIPT87: Invalid argument. at FixedColumns.min.js, line 29 character 123

when I use FixedColumns with IE7 and IE8. Looking at the FixedColumns code it occurs at the line

[code]oGrid.dt.style.width = iRemainder+"px";[/code]

and the error occurs because iRemainder is negative, which in turn is because iTotal is zero. Furthermore I get lots of these errors.

I think part of the problem is that as far as I can work out $(window).resize is triggered in IE7/8 not just when the window is resized but also when an element in the window is resized.

This does not happen on the example pages, so obviously there's something different about my table/CSS that's provoking the problem. Any ideas on how to change the CSS to circumvent the problem or else patch FixedColumns so the problem doesn't happen much appreciated.

Campbell

Replies

  • greenflashgreenflash Posts: 58Questions: 5Answers: 0
    I've managed to fix this in FixedColumns by (a) filtering out bogus resize events and (b) unbinding the resize handler while a resize event is being dealt with:

    [code]
    var winWidth = $(window).width();
    var winHeight = $(window).height();

    var windowResizeHandler = function() {
    // Chck whether it's a genuine window resize (IE7/8 also trigger a
    // resize when an element in the window is resized)
    var winNewWidth = $(window).width();
    var winNewHeight = $(window).height();
    if ((winNewWidth == winWidth) && (winNewHeight == winHeight))
    {
    return;
    }
    winWidth = winNewWidth;
    winHeight = winNewHeight;
    // Stop any more resize events while we're dealing with this one
    $(window).unbind('resize', windowResizeHandler);
    that._fnGridLayout.call( that );
    $(window).bind('resize', windowResizeHandler);
    };

    $(window).bind('resize', windowResizeHandler);
    [/code]

    Campbell
  • greenflashgreenflash Posts: 58Questions: 5Answers: 0
    Even with the changes above, some calls to _fnGridLayout() were still getting through that resulted in the SCRIPT87 error. I've dealt with these by adding the code

    [code]
    if (iTotal == 0)
    {
    return;
    }
    [/code]

    just after

    [code]
    var iTotal = $(oGrid.wrapper).width();
    [/code]

    I'm sure this isn't the best way of dealing with the problem ...

    Campbell
  • jhaitasjhaitas Posts: 32Questions: 0Answers: 0
    bump for this ... hopefully Allan sees it

    I came to the same solution as greenflash before I saw this post

    For the record...
    This bug for me was triggered because I have multiple tables - each in a jQuery UI tab ... on tab switching the resize event that fires _fnGridLayout() was being called on the table that was not going to be showing.
  • kcakebreadkcakebread Posts: 1Questions: 0Answers: 0
    I am getting a very similar error ("SCRIPT 87: Invalid argument" setting width property during redraw) when calling fnSetFilter in IE 7/8 (no issue in IE9). I'm referencing dataTables 1.9.4, jquery 1.8.2, and jquery.ui 1.8.23 from the Microsoft CDN. When I change the dataTables reference to 1.9.3, the problem disappears.

    Some chain of events causes fnSetFilter to result in a call to fnScrollDraw, during which I get the error on line 3338:
    // Apply all widths in final pass. Invalidates layout only once because we do not
    // read any DOM properties.
    _fnApplyToChildren( function(nToSize, i) {
    nToSize.style.width = aApplied[i];
    }, anHeadToSize );
  • accchowaccchow Posts: 1Questions: 0Answers: 0
    The root problem is the $(oGrid.wrapper).width() is undefined,
    so I fixed it by assign the width value again.
    For example,
    in your javascript script to create the fixcolumn object
    o=new FixedColumns(...);
    add the following statement to assign the width again
    $(o.dom.grid.wrapper).width($(o.dom.grid.wrapper).width());
  • pumupumu Posts: 1Questions: 0Answers: 0
    From Spain... thanks a lot greenflash. Your solution was perfect for the problem that I had.
  • allanallan Posts: 63,238Questions: 1Answers: 10,418 Site admin
    Can someone link me to a test case showing this issue so I can fix the underlying problem?

    Allan
This discussion has been closed.