Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter widget - filter column by multiple values #717

Open
roeycohen opened this issue Sep 7, 2014 · 6 comments
Open

filter widget - filter column by multiple values #717

roeycohen opened this issue Sep 7, 2014 · 6 comments

Comments

@roeycohen
Copy link

hi,

is it possible using the filer-select option to select more than one options?

maybe something like this:

image

thanks,
Roey

@Mottie
Copy link
Owner

Mottie commented Sep 7, 2014

Hi @roeycohen!

Is that a custom select? How are the checkboxes getting added?

Anyway, currently, this isn't possible to do with a select within the filter row; but here is a demo to add an external multi-select:

HTML

<select class="search" multiple>
    <option></option> <!-- empty option to clear filter -->
</select>

Script

var targetColumn = 3; // age column

$('table').tablesorter({
    widgets: ['zebra', 'filter'],
    widgetOptions: {
        filter_columnFilters : true
    },
    initialized : function(table) {
        // get all values from the age column
        var opts = $.tablesorter.filter.getOptionSource( table, targetColumn );
        $('.search')
            .append('<option>' + opts.join('</option><option>') + '</option>')
            .on('change', function(){
                var filters = [];
                // set filter for "Age" column
                filters[targetColumn] = $(this).find(':selected').map(function(){
                    return this.value;
                }).get().join('|');
                $.tablesorter.setFilters( table, filters, true );
            });
    }
});

@roeycohen
Copy link
Author

Hi,

Thank you for you answer.

The sample isn't very elegant, so for now i'll pass it :)

About the special drop down, it is a custom select, you may find it here:
http://dropdown-check-list.googlecode.com/svn/trunk/doc/dropdownchecklist.html

this project is not being maintained anymore... (so maybe embedding its code directly in the tablesorter library may be better).

Roey

@bryancorrell
Copy link

This would be an excellent addition - the external select is not very user-friendly. Any plans to add this support?

@KevinDuganJr
Copy link

I tried the demo(http://jsfiddle.net/abkNM/3935/) and it just has a lot of [object Object] in it. I tried implementing the source to what I have and couldn't get it working either. And the option @roeycohen linked is 404 not found, doh!

If selecting multiple options within a filter could be added, that would be very awesome addition to an already awesome plugin! Mottie, thank you for what you've done already!

@Mottie
Copy link
Owner

Mottie commented Jul 22, 2017

Hi @Zero2Cool!

Thanks! I've been super busy so I haven't had much time to work on this plugin, but I did update the demo - http://jsfiddle.net/abkNM/9473/

@favorini
Copy link

favorini commented Mar 28, 2019

I'd love to see this option. Thanks!

P.S. Could also use Ctrl- and Shift-Click to select multiple items, if checkboxes don't work out. (But I like the checkboxes. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants