Reputation: 379
Row Content Sample: (this content is loaded from a json array txt file)
<div class='debug'><a href='/DH033368-4041-SR-0910-00005-006-0-CPC-20131105-1652/debug/DH033368-4041-SR-0910-000-Stage 1B Client Review-filteredCommentsXFDF.xml' target='_blank'>[webdav]</a> : /Company Home/filteredCommentsXFDF.xml</div>
I need to either find the debug class within a DataTable row(s) or search for '/debug/' in the "href" attribute and if found hide the row.
Javascript is not my strong suite. Any help is appreciated.
What I have so far:
$("#hide").click(function() {
console.log('HIDE');
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return $(table.row(dataIndex).node()).data().search("/debug/");
}
);
table.draw();
});
$("#reset").click(function() {
console.log('RESET');
$.fn.dataTable.ext.search.pop();
table.draw();
});
Thanks
Upvotes: 1
Views: 607
Reputation: 85528
Use to$()
to convert the row node to a jQuery instance. This is more easy to work with. Then simply test the <div>
and the <a>
href
for the desired matches :
$('#hide').click(function() {
$.fn.dataTable.ext.search.push(function(settings, data, dataIndex) {
var $row = table.row(dataIndex).nodes().to$();
return $row.find('div').hasClass('debug') ||
$row.find('a').attr('href').indexOf('/debug/')>-1
})
table.draw()
})
demo -> http://jsfiddle.net/3co6Lvkx/
Upvotes: 1