Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3721026
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:24:56+00:00 2026-05-19T05:24:56+00:00

I’m displaying a table with multiple rows and columns. I’m using a JQUERY plugin

  • 0

I’m displaying a table with multiple rows and columns. I’m using a JQUERY plugin called uiTableFilter which uses a text field input and filters (shows/hides) the table rows based on the input you provide. All you do is specify a column you want to filter on, and it will display only rows that have the text field input in that column. Simple and works fine.

I want to add a SECOND text input field that will help me narrow the results down even further. So, for instance if I had a PETS table and one column was petType and one was petColor — I could type in CAT into the first text field, to show ALL cats, and then in the 2nd text field, I could type black, and the resulting table would display only rows where BLACK CATS were found. Basically, a subset.

Here is the JQUERY I’m using:

   $("#typeFilter").live('keyup', function() {

    if ($(this).val().length > 2 || $(this).val().length == 0)
  {
                var newTable = $('#pets');
  $.uiTableFilter( theTable, this.value, "petType" );
  } 

   }) // end typefilter

   $("#colorFilter").live('keyup', function() {
    if ($(this).val().length > 2 || $(this).val().length == 0)
  {
  var newTable = $('#pets');
  $.uiTableFilter( newTable, this.value, "petColor" );

  } 

   }) // end colorfilter

Problem is, I can use one filter, and it will display the correct subset of table rows, but when I provide input for the other filter, it doesn’t seem to recognize the visible table rows that are remaining from the previous column, but instead it appears that it does an entirely new filtering of the original table. If 10 rows are returned after applying one filter, the 2nd filter should only apply to THOSE 10 rows. I’ve tried LIVE and BIND, but not working.

Can anyone shed some light on where I’m going wrong? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:24:57+00:00Added an answer on May 19, 2026 at 5:24 am

    The uiTableFilter plugin doesn’t support what you’re trying to do. A quick look at the source reveals this:

    elems.each(function(){
        var elem = jQuery(this);
        jQuery.uiTableFilter.has_words(getText(elem), words, false)
            ? matches(elem)
            : noMatch(elem);
    });
    

    and that expands to (essentially) this:

    elems.each(function(){
        var elem = jQuery(this);
        jQuery.uiTableFilter.has_words(getText(elem), words, false)
            ? elem.show()
            : elem.hide();
    });
    

    So all it does is spin through all the rows, .show() those that match, and .hide() those that don’t; uiTableSorter doesn’t pay attention to the current shown/hidden state of the rows and there’s no way to tell it to filter on multiple columns.

    If you really need your desired functionality then you can modify the plugin’s behavior (the code is pretty small and simple) or just write your own. Here’s a stripped down and simplified version that supports multiple filters and is a more conventional jQuery plugin than uiTableFilter:

    (function($) {
        $.fn.multiFilter = function(filters) {
            var $table = $(this);
            return $table.find('tbody > tr').each(function() {
                var tr = $(this);
    
                // Make it an array to avoid special cases later.
                if(!$.isArray(filters))
                    filters = [ filters ];
    
                howMany = 0;
                for(i = 0, f = filters[0]; i < filters.length; f = filters[++i]) {
                    var index = 0;
                    $table.find('thead > tr > th').each(function(i) {
                        if($(this).text() == f.column) {
                            index = i;
                            return false;
                        }
                    });
                    var text = tr.find('td:eq(' + index + ')').text();
                    if(text.toLowerCase().indexOf(f.word.toLowerCase()) != -1)
                        ++howMany;
                }
                if(howMany == filters.length)
                    tr.show();
                else
                    tr.hide();
            });
        };
    })(jQuery);
    

    I’ll leave error handling and performance as an exercise for the reader, this is just an illustrative example and I wouldn’t want to get in the way of your learning. You could wire it up something like this:

    $('#type').keyup(function() {
        $('#leeLooDallas').multiFilter({ column: 'petType', word: this.value });
    });
    $('#color').keyup(function() {
        $('#leeLooDallas').multiFilter([
            { column: 'petType',  word: $('#type').val() },
            { column: 'petColor', word: this.value       }
        ]);
    });
    

    And here’s a live example (which assumes that you’re going to enter something in “type” before “color”): http://jsfiddle.net/ambiguous/hdFDt/1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.