fnRowCallback and sAjaxSource giving me "undefined" aData

fnRowCallback and sAjaxSource giving me "undefined" aData

wengolewengole Posts: 6Questions: 0Answers: 0
edited October 2011 in DataTables 1.8
Hi,

I'm trying to create a conditional format on rows where a field is not empty. However when I was testing against the field using aData[8], nothing was happening. To try and figure out why I added an alert for aData[8] to the callback and every single row was undefined. I checked other fields and they all seem to be undefined. Can anyone see where I'm going wrong and help please?

[code]
$(document).ready(function() {
/* Init dataTables */
var portsTable = $('#portsTable').dataTable({
"bJQueryUI": true,
"bPaginate": false,
"sAjaxSource": $('#actionForm').attr('action') + '/manager/getTable',
"bDeferRender": true,
"aoColumns": [
{"mDataProp": "port" },
{"mDataProp": "hostname" },
{"mDataProp": "friendlyname" },
{"mDataProp": "localip0" },
{"mDataProp": "localip1" },
{"mDataProp": "macaddress0" },
{"mDataProp": "macaddress1" },
{"mDataProp": "lastonline" },
{"mDataProp": "offlinesince" },
],
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
alert(aData);
$(nRow).addClass("isOfflineHighlight");
return nRow;
}
});

/* Apply jEditable to the table */
$('td:eq(2)', portsTable.fnGetNodes()).editable($('#actionForm').attr('action') + '/manager/updateName', {
"callback": function( sValue, y ) {
var aPos = portsTable.fnGetPosition( this );
portsTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
"submitdata": function ( value, settings ) {
var aPos = portsTable.fnGetPosition( this );
var aData = portsTable.fnGetData( this.parentNode );
return {
"port": aData[ aPos[1] - 2 ]
};
},
"height": "14px"
} );
});
[/code]

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    > aData[8]

    But you are using an object rather than an array. Don't you want to do something like aData.offlinesince ?

    Allan
  • wengolewengole Posts: 6Questions: 0Answers: 0
    *facepalm*

    Yes that's exactly it. Always helps to have a second pair of eyes :)

    Thanks.
This discussion has been closed.