serverside, objectbased reading does not work

serverside, objectbased reading does not work

ysor123ysor123 Posts: 9Questions: 0Answers: 0
edited June 2011 in General
Hallo,

i have a problem using serverside & objectbased data with datatables. (aaData rows as Objects)

Agent: Moz. FF 3.6.17 (only tried on this atm)
DataTables: 1.7.6
jQuery: 1.6.1
jQueryUI: 1.8.12
jQuery-/UI Plugins: only DataTables
DataTables Plugins: none

This is the initialisation i used to test it:
[code]

$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "debug.php",
"aoColumns": [
{ "mDataProp": "col_1_prop_name" },
{ "mDataProp": "col_2_prop_name" },
{ "mDataProp": "col_3_prop_name" }
]
} );
} );

[/code]

Inside body:
[code]



col 1
col 2
col 3










[/code]

Server response JSON:
[code]
{
"sEcho" : 1,
"iTotalRecords" : 9,
"iTotalDisplayRecords" : 9,
"aaData": [
{ "col_1_prop_name" : 2, "col_2_prop_name" : "some data 1" , "col_3_prop_name" : "test 1" },
{ "col_1_prop_name" : 3, "col_2_prop_name" : "some data 2" , "col_3_prop_name" : "test 2" },
{ "col_1_prop_name" : 4, "col_2_prop_name" : "some data 3" , "col_3_prop_name" : "test 3" },
{ "col_1_prop_name" : 5, "col_2_prop_name" : "some data 4" , "col_3_prop_name" : "test 4" },
{ "col_1_prop_name" : 6, "col_2_prop_name" : "some data 5" , "col_3_prop_name" : "test 5" },
{ "col_1_prop_name" : 7, "col_2_prop_name" : "some data 6" , "col_3_prop_name" : "test 6" },
{ "col_1_prop_name" : 8, "col_2_prop_name" : "some data 7" , "col_3_prop_name" : "test 7" },
{ "col_1_prop_name" : 9, "col_2_prop_name" : "some data 8" , "col_3_prop_name" : "test 8" },
{ "col_1_prop_name" : 10, "col_2_prop_name" : "some data 9" , "col_3_prop_name" : "test 9" }
]
}
[/code]

DataTables warning (table id = 'example'): Added data (size undefined) does not match known number of columns (3)

Replies

  • zupozupo Posts: 2Questions: 0Answers: 0
    I had the same problem yesterday. Turns out I was not using the latest datatables.js. The objectbased data was introduced in 1.8 version.
  • ysor123ysor123 Posts: 9Questions: 0Answers: 0
    Well. thats it. Tried everything, even the simplest things just to be sure that it realy does not work before ask. Well but I did not notice that 1.8 is now final and not beta anymore, so this may be the reason.

    Thx :-=
  • zupozupo Posts: 2Questions: 0Answers: 0
    Glad it helped. My head is still red for bumping it against the wall figuring it out :)
This discussion has been closed.