fnGetTds - oSettings.aoData[iRow] is undefined

fnGetTds - oSettings.aoData[iRow] is undefined

JanuszJasinskiJanuszJasinski Posts: 36Questions: 0Answers: 0
edited July 2013 in Plug-ins
Hi,

I am using the code below because as per http://datatables.net/forums/discussion/16329/search-and-sort-alters-data-when-using-fncreatedrow#Item_4 I was told to use fnGetTds. However I am getting the error [code]oSettings.aoData[iRow] is undefined[/code] and it's highlighted in the vode below.

How can I replicate what I originally had by using fnGetTds???

[code]
$.fn.dataTableExt.oApi.fnGetTds = function (oSettings, mTr) {
var anTds = [];
var anVisibleTds = [];
var iCorrector = 0;
var nTd, iColumn, iColumns;

/* Take either a TR node or aoData index as the mTr property */
var iRow = (typeof mTr == 'object') ?
oSettings.oApi._fnNodeToDataIndex(oSettings, mTr) : mTr;
var nTr = oSettings.aoData[iRow].nTr; // THIS IS WHERE I GET THE ERROR


/* Get an array of the visible TD elements */
for (iColumn = 0, iColumns = nTr.childNodes.length; iColumn < iColumns; iColumn++) {
nTd = nTr.childNodes[iColumn];
if (nTd.nodeName.toUpperCase() == "TD") {
anVisibleTds.push(nTd);
}
}

/* Construct and array of the combined elements */
for (iColumn = 0, iColumns = oSettings.aoColumns.length; iColumn < iColumns; iColumn++) {
if (oSettings.aoColumns[iColumn].bVisible) {
anTds.push(anVisibleTds[iColumn - iCorrector]);
}
else {
anTds.push(oSettings.aoData[iRow]._anHidden[iColumn]);
iCorrector++;
}
}

return anTds;
};



$(document).ready(function () {
var oTable = $('#example').dataTable({
"bProcessing": true,
"bScrollCollapse": true,
//"bSort": false,
"bServerSide": true,
"sAjaxSource": "data.asp",
"sServerMethod": "POST",
"sScrollX": "100%",
"aoColumnDefs": [{ "bSortable": false, "aTargets": [ 3,4,5,6,7,8,9,10,12,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 ] }] ,
/*
"fnCreatedRow": function (nRow, aData, iDisplayIndex) {
$("td:gt(2)", nRow).addClass('blue-link');
$('td:eq(3), td:eq(4)', nRow).click(function () {
$("#thedialog").attr('src', $(this).next('.dialog').attr("href"));
$("#somediv").dialog({
width: 800,
height: 600,
modal: true,
close: function () {
$("#thedialog").attr('src', "about:blank");
}
});
return false
});
},
*/
"fnInitComplete": function () {
new FixedColumns(oTable, {
"iLeftColumns": 3,
"sHeightMatch": "auto"
});
}
});

var anTds = oTable.fnGetTds($('td:gt(2)').css("color", "red"));
});



[/code]

Replies

This discussion has been closed.