Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
190
rated 0 times [  193] [ 3]  / answers: 1 / hits: 48827  / 14 Years ago, wed, august 11, 2010, 12:00:00

I'm trying to filter table rows in an intelligent way (as opposed to just tons of code that get the job done eventually) but a rather dry of inspiration.



I have 5 columns in my table. At the top of each there is either a dropdown or a textbox with which the user may filter the table data (basically hide the rows that don't apply)



There are plenty of table filtering plugins for jQuery but none that work quite like this, and thats the complicated part :|


More From » jquery

 Answers
24

Here is a basic filter example http://jsfiddle.net/urf6P/3/



It uses the jquery selector :contains('some text') and :not(:contains('some text')) to decide if each row should be shown or hidden. This might get you going in a direction.



EDITED to include the HTML and javascript from the jsfiddle:



$(function() {    
$('#filter1').change(function() {
$(#table td.col1:contains(' + $(this).val() + ')).parent().show();
$(#table td.col1:not(:contains(' + $(this).val() + '))).parent().hide();
});

});

[#95953] Monday, August 9, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zaynerogerb

Total Points: 454
Total Questions: 109
Total Answers: 97

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
zaynerogerb questions
;