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

Integrating quicksearch #160

Closed
ghost opened this issue Oct 23, 2012 · 7 comments
Closed

Integrating quicksearch #160

ghost opened this issue Oct 23, 2012 · 7 comments

Comments

@ghost
Copy link

ghost commented Oct 23, 2012

Hi,

I integrated quicksearch to search the entire table via a single input:

https://github.com/riklomas/quicksearch

However, this doesn't really work with pagination enabled, it only searches the currently visible page.

Is there any sample of how I should convert this to a widget? I checked the filter widget, but that seems really complex.

All I want is that it searches the entire table and keeps paginating the table.

I understand this is going to be added in 3.0 - but unfortunately I need this functionality at this very moment. So any help is appreciated.

Thank you.

@hereswhatidid
Copy link

Try setting the removeRows option to false in your Pager Options. What the Pager does if that is set to true (default) is that it basically recreates the table body every time you change the page. This would then cause your search filter to only search what's currently visible.

@Mottie
Copy link
Owner

Mottie commented Oct 23, 2012

Hi wesleyh!

I'll try to look at this tomorrow, but it is as @hereswhatidid says, set the removeRows option to false.

Then if you can get that quick search plugin to add a class name of filtered to the row, then the pager will properly paginate the table.

@ghost
Copy link
Author

ghost commented Oct 24, 2012

Hi, thanks for the fast response! I have added "filtered" on rows that are going to be hidden, and removed it when these rows are going to be shown. However, it still displays all results on the first page. Do I need to call something in the tablesorter plugin to get it to reflect the new state?

Thanks again.

@Mottie
Copy link
Owner

Mottie commented Oct 24, 2012

Ahhh sorry!

Hmmm, it looks like you might have to add the class "hasFilters" to the table itself before initializing the pager plugin.

Then if you need to, trigger the filter end event after the quicksearch as initialized to make it update:

$('table').trigger('filterEnd');

If that doesn't work, I'll dig into it more later today.

@ghost
Copy link
Author

ghost commented Oct 24, 2012

This works beautifully! Thank you for your hard work on this plugin, great job.

@Mottie
Copy link
Owner

Mottie commented Oct 25, 2012

Ok, with the latest update (v2.4.6) you no longer need to add the "hasFilters" class to the table. And in addition to triggering the filterEnd event, you can also trigger the updateComplete event to update the pager.

@Mottie
Copy link
Owner

Mottie commented Apr 19, 2013

Please see this comment for working code & a demo.

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

2 participants