fnRowCallback and sAjaxSource giving me "undefined" aData
fnRowCallback and sAjaxSource giving me "undefined" aData
wengole
Posts: 6Questions: 0Answers: 0
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]
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]
This discussion has been closed.
Replies
But you are using an object rather than an array. Don't you want to do something like aData.offlinesince ?
Allan
Yes that's exactly it. Always helps to have a second pair of eyes :)
Thanks.