Reputation: 2175
Hi I am developing one application using asp.net and jquery where i have one gridview. I am trying to hide rows of grid view based on certain condition. I tried with some jquery code as below.
for (var k = 0; k < result.length; k++)
{
$('#<%= GridView1.ClientID %> input[type="hidden"]').each(function () {
if($(this).val()==result[k])
{
//Want to hide kth row of gridview
}
});
}
And as soon as i hide the row then i want to break the inner loop. I tried by putting break but it is not working. May I have some inputs on the above problem? Thank you.
Upvotes: 1
Views: 1399
Reputation: 28741
Yo need to fetch the parent row in which hidden filed lies and hide it.
$('#<%= GridView1.ClientID %> input[type="hidden"]').each(function () {
if($(this).val()==result[k])
{
//$(this).closest('tr').css('display','none');
$(this).closest('tr').find('input[type="checkbox"]').prop('disabled',true);
return false;
}
});
closest() function searches up the DOM tree i.e selected element's ancestor and return false
is used to break out of each()
function.
Upvotes: 3