oSettings null on Zero configuration fnAddData

oSettings null on Zero configuration fnAddData

stuart.laddstuart.ladd Posts: 3Questions: 0Answers: 0
edited November 2009 in General
Hi,
I've just set up a basic table to test the library for a project I'm working on. Stumbling at the first hurdle: when I do fnAddData() on my table the debugger (FF3 & Chrome on ubuntu) tells me oSettings is null. This happened with zero configuration and with some set up variables (oLanguage).

I scaled back to a simple-as-possible page: I have a basic table with 3 columns and an id of 'friends' and the following script. thead is set up with headings and tbody is set up a row of empty cells.
[code]
var dtable = $("friends");

$(document).ready(function() {
dtable.dataTable();

});
[/code]

I've added a button to test adding a line calling this:
[code]javascript:dtable.fnAddData(['stu', '01329', 'a.jpg'], false)[/code]

But when I click I get the exception (chrome and firebug):
[code]
Cannot read property 'aoColumns' of null
[/code]

on line 194 of the .min.js which is:
[code]
_fnAddData(oSettings,aData){if(aData.length!=oSettings.aoColumns.length){alert("Warning - added data does not match known number of columns");
[/code]

Can anyone help?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi stuart.ladd,

    Try this:

    [code]
    var dtable;
    $(document).ready(function() {
    dtable = $("friends").dataTable();
    });
    [/code]
    You were assigning the result of the jQuery selector $("friends") to dtable, not the DataTables resultant object, which is required, and what the above code does.

    Regards,
    Allan
  • stuart.laddstuart.ladd Posts: 3Questions: 0Answers: 0
    Thank you. I guess I didn't read the example closely enough!
  • stuart.laddstuart.ladd Posts: 3Questions: 0Answers: 0
    Also, I was missing the # on the id! Got it working now thanks.
This discussion has been closed.