sName complications

sName complications

pwc1011pwc1011 Posts: 62Questions: 0Answers: 0
edited January 2010 in General
For some reason, when I add "sName" to the aoColumn definition, my table no longer displays the results.

define the table...

[code]

$(document).ready(function () {
$("#tester").dataTable(
{ "aoColumns": [
{ "sName": "Details", "sClass": "center", "bSortable": false, "bVisible": true },
{ "sName": "NameStr", "sClass": "center", "bSortable": true, "bVisible": true },
{ "sName": "AgeInt", "sClass": "center", "bSortable": true, "bVisible": true },
{ "sName": "Id", "sClass": "center", "bSortable": false, "bVisible": false }
],
"sAjaxSource": "../../TestJson/EntityListData",
"aaSorting": [[2, "desc"]]
});
});

[/code]

results returned...

[code]
{
"iTotalRecords":12,
"iTotalDisplayRecords":12,
"sEcho":1,
"sColumns":"Details, NameStr, AgeInt, Id",
"aaData":[
["\u003cimg src=\u0027../../images/details_open.png\u0027 class=\u0027_rowDetailClick\u0027\u003e","Penny","45","9"],
["\u003cimg src=\u0027../../images/details_open.png\u0027 class=\u0027_rowDetailClick\u0027\u003e","Sue","40","4"],
["\u003cimg src=\u0027../../images/details_open.png\u0027 class=\u0027_rowDetailClick\u0027\u003e","Bill","34","6"],
["\u003cimg src=\u0027../../images/details_open.png\u0027 class=\u0027_rowDetailClick\u0027\u003e","Betsy","33","10"],
["\u003cimg src=\u0027../../images/details_open.png\u0027 class=\u0027_rowDetailClick\u0027\u003e","Pat","33","7"],
["\u003cimg src=\u0027../../images/details_open.png\u0027 class=\u0027_rowDetailClick\u0027\u003e","Suzy","28","12"],
["\u003cimg src=\u0027../../images/details_open.png\u0027 class=\u0027_rowDetailClick\u0027\u003e","Slim","26","11"],
["\u003cimg src=\u0027../../images/details_open.png\u0027 class=\u0027_rowDetailClick\u0027\u003e","Bob","23","2"],
["\u003cimg src=\u0027../../images/details_open.png\u0027 class=\u0027_rowDetailClick\u0027\u003e","Jane","23","5"],
["\u003cimg src=\u0027../../images/details_open.png\u0027 class=\u0027_rowDetailClick\u0027\u003e","Sal","22","8"]
]
}
[/code]

Any idea what I'm doing wrong?

(btw... it all works as expected without the sName in the def)

Follow Up: If I remove the sColumns from the data returned, it works with sName.

Follow Up 2: for some reason, this code does not work. I'm tracing through it, and everything added to aData fter the first column is null (undefined).

[code]

if (bReOrder) {
2468 /* If we need to re-order, then create a new array with the correct order and add it */
2469 var aData = [];
2470 for (var j = 0, jLen = oSettings.aoColumns.length; j < jLen; j++) {
2471 aData.push(json.aaData[i][aiIndex[j]]);
2472 }
2473 _fnAddData(oSettings, aData);
2474 }

[/code]

Patrick

Replies

  • pwc1011pwc1011 Posts: 62Questions: 0Answers: 0
    Figured it out...

    If the values returned in sColumns have a space after the comma, it fails to process the data after the first column.

    so if this "sColumns":"Details, NameStr, AgeInt, Id" from the above example is changed to this
    "sColumns":"Details,NameStr,AgeInt,Id", all is good.

    Patrick
  • rewenrewen Posts: 74Questions: 2Answers: 0
    edited January 2011
    I had the same issue. Figured it out just before finding this post. Might be good to mention in docs that spaces should not be used :)
This discussion has been closed.