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

widget filter feature request option for blur event #1522

Open
CiTRO33 opened this issue Mar 8, 2018 · 3 comments
Open

widget filter feature request option for blur event #1522

CiTRO33 opened this issue Mar 8, 2018 · 3 comments

Comments

@CiTRO33
Copy link

CiTRO33 commented Mar 8, 2018

Hello Mottie,

would it be possible to get a filterwidget option to control the blur event if the search is triggered?
https://github.com/Mottie/tablesorter/blob/master/js/widgets/widget-filter.js#L873

I would like to control the filtersearch is only triggered with the enter key or programmatically (search event).
I use the pager widget with serverside processing.
So f you need to filter multiple columns at the same time, on every "tab"-key the search is triggered and a ajax call is made. On complex tables the search take some time (1,2,3,... seconds) to complete.

If you need more Information, or you know a better way please leave a post.

Thank you very much.

Greetings

@Mottie
Copy link
Owner

Mottie commented Mar 8, 2018

Hi @CiTRO33!

Hmm, maybe the easiest solution would be to remove the blur event listener (demo):

$(function() {
  $("table").tablesorter({
    theme: "blue",
    widgets: ["zebra", "filter"],
    widgetOptions: {
      filter_liveSearch: false
    },
    initialized: function(table) {
      var namespace = table.config.namespace + "filter";
      $(table).find(".tablesorter-filter").off("blur" + namespace);
    }
  });
});

@CiTRO33
Copy link
Author

CiTRO33 commented Mar 8, 2018

thanks for the fast response and the great idea.
FYI: To prevent the trigger on "tab"-key the keyup event must be remove too.

$(table).find('.tablesorter-filter').off('blur' + namespace + ' keyup' + namespace);
http://jsfiddle.net/856bzzeL/1384/

@CiTRO33 CiTRO33 closed this as completed Mar 8, 2018
@CiTRO33
Copy link
Author

CiTRO33 commented Mar 9, 2018

Hi @Mottie ,
today i had some time to test this a little bit more.
If i remove the keyup - event, i have a little problem:

I enter "c" in column "Major" , "tab"-key to column "Sex" enter "fe" and comfirm with "enter"-Key
-> filter is apply
now i remove all filters from columns "Major" and "Sex", pressing enter -> filter is not removed.

I would like to achieve that only "enter"-Key will trigger the search.

Maybe is it possible with a new filter option where i can set key codes/events, which only will be accepted? ( liveSearch must be false)
Like: filter_searchTrigger: [ 13 , 'search' ] default = false = current behavior
with this example only 13 = "enter" and the programmatically "search" event will trigger a search.

Possible values:
Numbers = keycode e.g. 13(enter), 27 (escape)
string = events e.g. 'search', 'blur'
object = combination e.g. ctrl + enter like {keycode:13,ctrl: true, shift:false, alt:false}

If you have need more information or you have some other ideas let me know.
Thank you!

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