empty list in internet explorer causes error @ line 1929

empty list in internet explorer causes error @ line 1929

mythosmintmythosmint Posts: 2Questions: 0Answers: 0
edited May 2009 in General
First of all great plugin works very well. I only have a small problem. At first it just shows an empty list. In firefox no problems, but in Internet Explorer 7 it gives me an error: Line: 1929 Error: Invalid argument.

Any ideas?

Here is my code:

[code]
$(document).ready(function() {
$('#example').dataTable({

"aaSorting": [ ], // prevent initial sort
"bProcessing": true,
"sPaginationType": "full_numbers", // use different pagination style
"sDom": '<"top"lprt><"bottom"if<"clear">',

"aaData": [],
"aoColumns": []
}); } );
[/code]
DataTables v1.4.3 & v1.5b7
jQuery v1.3.1


After I run a search which spits back some data in IE its fine. Its just the very first time when the list is empty.

And if anyone wants to know I'm using java Servlet to connect to an oracle database and send back a List that I then parse with JSTL to create the aaData & aoColumns.

Servlet Code:

List searchResults = Service.getSearchResult(sqlStatement);

// put into request
request.setAttribute("searchResults", searchResults);

.jsp Code:
[code]
"aaData": [
["",],
],

"aoColumns": [


{ "sTitle": ""},
]
[/code]

Works great!

How do you get those cool code boxes to work?

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Hi mythosmint,

    In your initialisation code you have aaData: [], which means that you are not passing any to DataTables - but when you say you "run a search" which puts some data into it - how does this work. If you don't have any data to give DataTables, its probably best just not to give it aaData. Also Line 1929 - is that in 1.4.3 or 1.5b7?

    Thanks for the code snippet! Hopefully people will find it useful!

    Also regarding the code boxes, just use [ code ] and [/ code ] (without the spaces). It doesn't work in Safari for some reason... On the to-do list :-)

    Allan
  • mythosmintmythosmint Posts: 2Questions: 0Answers: 0
    edited May 2009
    Thanks for the help. It got me thinking that I probably shouldn't initialize the plug-in if there is no data. So I'm checking what I'm getting from the Servlet and only initializing the plug-in if its > 0.

    I'm sure there is a better way for what I'm doing. What I'm doing now is basically creating the HTML that gets loaded/parsed into JavaScript. It would be better to do an AJAX call to and go directly to JavaScript. But I do what I want!

    Also Line 1929 was in 1.4.3

    Here it is if anyone wants it:

    [code]


    $('#example').dataTable({

    "aaSorting": [ ], // prevent initial sort
    "bProcessing": true,
    "sPaginationType": "full_numbers", // use different pagination style
    "sDom": '<"top"lprt><"bottom"if<"clear">',

    "aaData": [



    [
    ""


    ,// Don't print out comma on last entry



    ]


    ,



    ],

    "aoColumns": [





    { "sTitle": ""}


    ,





    ]


    });


    [/code]
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    1929 in 1.4.3 is nTd.colSpan = oSettings.aoColumns.length;

    If that giving you an error, then that would suggest that DataTables doesn't know of any columns. Are you getting your column information from the HTML? If so you need the standard .... stuff. If not then you need to define aoColumn in your initialisation. DataTables most certainly should cope with empty data - aaData being empty should be okay - I just wanted to check that.

    Allan
This discussion has been closed.