Hello,
do you plan to allow the use of wildcards *, ?, % in quick searcg box, and other filter queries ?
Or is it a hook way to perform it ?
Thanks, keep away from Covid
François
search box , queries
Re: search box , queries
By default, MySQL database (and most others) use different characters than * and ? as wildcards:
Anyway, users are used to using "*" and "?" instead, which is more windows-like.
In a project for a customer I did some hooks-only replacement of "*" by "%" and "?" by "_" just before execution of search. In that project, I only did it for a certain tableview, because there were specific requirements for search. So I did those changes in TABLENAME-tv.js. But if you want to enable that wildcard-replacement globally, you can also write the following script in hooks/header-extras.php:
Result
Searching for "K*be*"
returns Kaffeebecher and Kugelschreiber
Searching for "K*be??er"
returns Kaffeebecher
Small backdraw and workaround
On search, for a millisecond you can see the charater replacement and perhaps red underlined fragments due to spelling correction of your browser. If you, like me, dislike this, you can hide the searchbox immediately before replacement. Just uncomment the following line and it will look much better from my personal opinion.
Result with hiding searchbox:
Hope this helps someone and you like this hooks-only enhancement. Any feedback is welcome!
PS: On that specific customer project the resolveSearchString() function is much more elaborated. For example, if search contains a slash like in "3/117", I'm building a custom search pattern with leading zeroes like "00003/0000000117". This makes it easier for users to quickly search for records if there are naming conventions or defined patterns.
- % (percent)
for any number of characters - _ (underscore)
for exactly one character
Anyway, users are used to using "*" and "?" instead, which is more windows-like.
In a project for a customer I did some hooks-only replacement of "*" by "%" and "?" by "_" just before execution of search. In that project, I only did it for a certain tableview, because there were specific requirements for search. So I did those changes in TABLENAME-tv.js. But if you want to enable that wildcard-replacement globally, you can also write the following script in hooks/header-extras.php:
Code: Select all
<!-- file: hooks/header-extras.php -->
<script>
const wildcard_search = true; // toggle this for testing purposes
jQuery(document).ready(function() {
if (wildcard_search) {
resolveSearchString(false);
$j('form[name=myform]').on('submit', function() {
// $j('#SearchString').parent().addClass("hidden");
resolveSearchString();
});
}
});
function resolveSearchString(on = true) {
const e = $j('#SearchString');
let val = e.val();
if (on) {
if (!val.length || val.search('%') >= 0) return;
e.val(val.replaceAll('*', '%').replaceAll('?', '_'));
} else {
e.val(val.replaceAll('%', '*').replaceAll('_', '?'));
}
}
</script>
Searching for "K*be*"
returns Kaffeebecher and Kugelschreiber
Searching for "K*be??er"
returns Kaffeebecher
Small backdraw and workaround
On search, for a millisecond you can see the charater replacement and perhaps red underlined fragments due to spelling correction of your browser. If you, like me, dislike this, you can hide the searchbox immediately before replacement. Just uncomment the following line and it will look much better from my personal opinion.
Code: Select all
// $j('#SearchString').parent().addClass("hidden");
Hope this helps someone and you like this hooks-only enhancement. Any feedback is welcome!
PS: On that specific customer project the resolveSearchString() function is much more elaborated. For example, if search contains a slash like in "3/117", I'm building a custom search pattern with leading zeroes like "00003/0000000117". This makes it easier for users to quickly search for records if there are naming conventions or defined patterns.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: search box , queries
Many thanks Jan,
I knew the Mysql features, had 'nt the idea to use it in Quick Search !!!!
François
I knew the Mysql features, had 'nt the idea to use it in Quick Search !!!!
François