Accessing the table row during filtering with afnFiltering
Accessing the table row during filtering with afnFiltering
wellsoliver
Posts: 2Questions: 0Answers: 0
Hey all. I'd like to be able to access the table row itself during filtering b/c I am trying to sort by some data that's not displayed in the columns, but stored as row-level attributes in the HTML, e.g. . You can't use the jQuery selector "table tbody tr:eq(N)" because the rows are hidden. Something like:
[code]
$.fn.dataTableExt.afnFiltering.push(
function(settings, data, i) {
var tablerow = $("table#id tbody tr:eq(" + i + ")");
if (tablerow.attr("attr1") != "foo") {
return false;
}
return true;
}
);
[/code]
But like I said that won't work. Is there another way? Thanks.
[code]
$.fn.dataTableExt.afnFiltering.push(
function(settings, data, i) {
var tablerow = $("table#id tbody tr:eq(" + i + ")");
if (tablerow.attr("attr1") != "foo") {
return false;
}
return true;
}
);
[/code]
But like I said that won't work. Is there another way? Thanks.
This discussion has been closed.
Replies
[code]
$.fn.dataTableExt.afnFiltering.push(
function(settings, data, iDataIndex) {
var oTable = $('#' + oSettings.sTableId).dataTable();
var row = oTable.fnGetNodes(iDataIndex);
return $(row).attr("attr1") == "foo";
}
);
[/code]