jQuery hide all table rows which contain a hidden field matching a value
Posted
by Famous Nerd
on Stack Overflow
See other posts from Stack Overflow
or by Famous Nerd
Published on 2010-04-15T20:45:46Z
Indexed on
2010/04/15
21:03 UTC
Read the original article
Hit count: 211
Though I don't doubt this has been answered I cannot find a great match for my question.
I have a table for which I'd like to filter rows based on whether or not they contain a hidden field matching a value.
I understand that the technique tends to be "show all rows", "filter the set", "show/hide that filtered set"
I have the following jquery but I'm aweful with filter and my filtered set seems to always contain no elements.
my table is the usual
<table>
<tr><td>header></td><td> </tr>
<tr>
<td>a visible cell</td><td><input type='hidden' id='big-asp.net-id' value='what-im-filtering-on' />
</td>
</tr>
</table>
My goal is to be able to match on tr who's descendent contains a hidden input containing either true or false.
this is how I've tried the selector (variations of this) and I'm not even testing for the value yet.
function OnFilterChanged(e){
//debugger;
var checkedVal = $("#filters input[type='radio']:checked").val();
var allRows = $("#match-grid-container .tabular-data tr");
if(checkedVal=="all"){
allRows.show();
}
else if(checkedVal=="matched"){
allRows.show();
allRows.filter(function(){$(this).find("input[type='hidden'][id~='IsAutoMatchHiddenField']")}).hide();
}
else if(checkedVal=="unmatched"){
}
}
Am I way off with the filter? is the $(this) required in the filter so that i can do the descendant searching?
Thanks kindly
© Stack Overflow or respective owner