"Added data does not match" with associative array, works with regular array

"Added data does not match" with associative array, works with regular array

devgreerdevgreer Posts: 9Questions: 0Answers: 0
edited July 2013 in DataTables 1.8
I have datatables working with a regular array, i.e., one with no keys, but when I add keys, it gives me this error: "Added data does not match known number of columns".

The only thing I changed is the array. Here's the one that works:

{ "aaData": [
[
504,
"51d1dc9ddc757",
4,
"dmpdaleg",
"2",
"2013-07-01 14:46:36.471356",
14277448,
"logs.browse",
"index",
"BASE_LOG",
"[]"
]
] }

And here's the one that doesn't work:

{ "aaData": [
{
"id":504,
"request_id":"51d1dc9ddc757",
"user_id":4,
"client_name":"dmpdaleg",
"type":"2",
"time":"2013-07-01 14:46:36.471356",
"memory":14277448,
"object":"logs.browse",
"method":"index",
"category":"BASE_LOG",
"args":"[]"
}
] }

The javascript setup looks like this, a little stripped down for clarity:

[code]
oTable = jQuery("#data").dataTable({
sAjaxSource: Browse._get_url(),
aoColumns: [
{
bVisible: false,
bSearchable: false
},
{
"sClass": "control",
},
{},
{},
{},
{},
{},
{},
{},
{},
{},
]
});
[/code]

And the html looks like this:

[code]




Data ID


Request ID


User ID


Client


Type


Time


Memory


Object


Method


Category


Args



[/code]

Replies

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    You need to use mData if you want to use objects, in order to tell DataTables which object property to use for each column.

    Allan
  • devgreerdevgreer Posts: 9Questions: 0Answers: 0
    Thanks allan, but that doesn't work either. Neither does "mRender" for that matter. And neither does aoColumnDefs. I suspect there could be something wrong with my version, even though I'm almost positive it's 1.9.4, because of so many things going wrong I wonder if there's some link in the system I'm working on that goes to a 1.8 version. But $.fn.dataTable.version doesn't work either, nor does jQuery.fn.dataTable.version, so I have no way of knowing exactly what version is being loaded.
  • devgreerdevgreer Posts: 9Questions: 0Answers: 0
    Gah! Nevermind, I finally found that the software I'm working was linking to a 1.6 version, so I fixed that and now a lot of stuff is working.
This discussion has been closed.