-
Notifications
You must be signed in to change notification settings - Fork 754
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
Feature Request to Issue filter_searchTrigger #1522 #1546
base: master
Are you sure you want to change the base?
Conversation
New Option filter_searchTrigger Possible Values: bool = default, Number = keycode , String = events ( search, blur ), Objects = { keyCode : Number, alt: bool, ctrl: bool, shift: bool} Examples: filter_searchTrigger : false -> same als ['search', 'blur', 13] filter_searchTrigger : [13] -> Enter filter_searchTrigger :[ 13, 9] -> Enter and tab - key filter_searchTrigger : ['blur'] filter_searchTrigger : [{keyCode: 13, ctrl:true] -> ctrl + Enter
Hi @CiTRO33! Thanks for your work on this enhancement. I haven't actually tested the code, but I like the concept so far. Here are a few comments I have on the code I see:
|
js/widgets/widget-filter.js
Outdated
for (var t in searchTrigger){ | ||
// events | ||
var stType = typeof searchTrigger[t]; | ||
if(stType === "string" && event.type === searchTrigger[t]){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work? If the outer wrapper has event.type === 'search'
won't this only capture the 'search' and not the 'blur' event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case only the search event is bind to the table, so the blur event isn't triggered here
js/widgets/widget-filter.js
Outdated
// only allow keyCode | ||
for ( var t in searchTrigger ){ | ||
// events | ||
var stType = typeof searchTrigger[t]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be easier to read if searchTrigger[t]
was assigned to a variable:
var trigger = searchTrigger[t]; // for example, name it whatever you want
js/widgets/widget-filter.js
Outdated
skipSearch = false; | ||
break; | ||
} else if(stType === "object" ){ | ||
if(searchTrigger[t].hasOwnProperty('keyCode') && event.which === searchTrigger[t].keyCode){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The searchTrigger[t].hasOwnProperty('keyCode')
isn't really necessary here, it will work with just:
if ( event.which === tskeyCodes[ trigger.key ] ) {
js/widgets/widget-filter.js
Outdated
shift = false; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above three modifier key checks can be simplified into:
var ctrl= typeof trigger.ctrl === 'undefined' ? true : trigger.ctrl=== event.ctrlKey,
alt = typeof trigger.alt === 'undefined' ? true : trigger.alt === event.altKey;
shift = typeof trigger.shift === 'undefined' ? true : trigger.shift === event.shiftKey;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran out of time... I'll review the rest of the code later.
Code format, allow search event always, allow names in object mode like [ { keyCode:'tab', ctrl:false}], possible values see tskeyCodes
Hi, i commented the search event out. So it's get triggered always.
i agree, but when the default is i tried to format the code - but at the moment i have only notepad++ and the github-webeditor to format - sorry |
Hi @CiTRO33! I'm really sorry for not responding earlier. I've been crazy busy... new job, new baby, etc. I am trying to catch up with everything now. Would you be willing to update the documentation for this enhancement? Adding it to the demo would be awesome too! 😻 |
Hi @Mottie , |
Hey Mottie,
i created a pull request for the enhancement in Issue #1522.
Maybe you have some time to review and test the feature?
I created a fiddle: http://jsfiddle.net/856bzzeL/1568/
Option description:
to enable the feature the option filter_liveSearch must set to false
Possible Values:
bool = default
Number = keycode
String = events ( search, blur )
Objects = { keyCode : Number, alt: bool, ctrl: bool, shift: bool }
Examples:
filter_searchTrigger : false -> same als ['search', 'blur', 13]
filter_searchTrigger : [13] -> Enter
filter_searchTrigger :[ 13, 9] -> Enter and tab - key
filter_searchTrigger : ['blur']
filter_searchTrigger : [{keyCode: 13, ctrl:true}] -> ctrl + Enter