Good morning everyone, does anyone know if it is possible to search for two entries in one or more columns at the same time using quick search?
In the attached photo for example I have a table where fruit sales are stored. Each row contains the product (one fruit). I would like to search through the quick search, in the entire table, for two fruits at the same time (for example the KIWI BOERICA and KIWI SORELI). For example, if I write 'BOERICA SORELI' in the search, the search does not return any results.
I would like to use the quick search and not the detailed search
Quick search: search for two items at the same time
Quick search: search for two items at the same time
- Attachments
-
- appgini-ricerca-veloce.JPG (117.25 KiB) Viewed 4403 times
Re: Quick search: search for two items at the same time
Hello
Try searching : KIWI%o
You should have the 2 kiwi
% IS for any letter(s)
Try searching : KIWI%o
You should have the 2 kiwi
% IS for any letter(s)
Re: Quick search: search for two items at the same time
Thank you. In this case it works because they are both KIWIs but what if they were different fruits and I wanted to search for example KIWIs and APPLES? (in the table in question the apples are not present but they could be there and the user might want to search for 2 or three different products at the same time.
Can you use the quick search or do you have to use the advanced search?
Thanks for your help
Can you use the quick search or do you have to use the advanced search?
Thanks for your help
Re: Quick search: search for two items at the same time
Hi,
the actual answer is no, you cannot do it without adding some code. AppGini uses by default a wildcard search on the string you enter.
So if you say that you use the "space" as a delimiter for your search, you might try this:
in the hooks/TABLENAME.php -> _init function
In the _header function you need to add to the tableview case:
the actual answer is no, you cannot do it without adding some code. AppGini uses by default a wildcard search on the string you enter.
So if you say that you use the "space" as a delimiter for your search, you might try this:
in the hooks/TABLENAME.php -> _init function
Code: Select all
if (isset($_REQUEST['SearchString'])) {
$delimiter=' '; // change this if you want to use a different delimiter
$searchstring=$_REQUEST['SearchString'];
$QuerySearchableFields=array();
foreach($options->QueryFieldsQS as $fName => $fCaption)
if(stripos($fName, '<img') === false)
$QuerySearchableFields[$fName] = $fCaption;
$sssarray = explode($delimiter,makeSafe($searchstring)); // safe search stringarray
$options->QueryWhere = $options->QueryWhere ? $options->QueryWhere : " WHERE 1=1 ";
$s=array();
foreach($sssarray as $idx => $sss) {
if(count($QuerySearchableFields))
$s[]=implode(
" LIKE '%{$sss}%' OR ",
array_keys($QuerySearchableFields)
) . " LIKE '%{$sss}%'";
}
$options->QueryWhere.='AND ('.implode(' OR ',$s).' )';
$_REQUEST['NewSearch']=$searchstring;
$_REQUEST['SearchString']='';
}
Code: Select all
if (isset($_REQUEST['NewSearch'])) {
$search=$_REQUEST['NewSearch'];
$header='<%%HEADER%%><script>$j(function() {$j("#SearchString").val("'.$search.'");$j(".table-responsive td:not([colspan])").mark("' . html_attr($$search) . '", { className: "text-bold bg-warning", diacritics: false, separateWordSearch: 1 });})</script>';
}
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Quick search: search for two items at the same time
Thanks for your help. I'll try to follow your advice this week. Thank you
Re: Quick search: search for two items at the same time
error:
Fatal error: Uncaught Error: Attempt to assign property "QueryWhere" on null in /data/vhosts/........../hooks/Movimenti_acquisto_peso.php:117 Stack trace: #0 /data/vhosts/......../Movimenti_acquisto_peso_view.php(259): Movimenti_acquisto_peso_header() #1 {main} thrown in /data/vhosts/........./hooks/Movimenti_acquisto_peso.php on line 117
Fatal error: Uncaught Error: Attempt to assign property "QueryWhere" on null in /data/vhosts/........../hooks/Movimenti_acquisto_peso.php:117 Stack trace: #0 /data/vhosts/......../Movimenti_acquisto_peso_view.php(259): Movimenti_acquisto_peso_header() #1 {main} thrown in /data/vhosts/........./hooks/Movimenti_acquisto_peso.php on line 117
Re: Quick search: search for two items at the same time
Can you post your code here?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Quick search: search for two items at the same time
what code do you need? I entered the code you posted. If you need more info I can send what you need. Thank you
Re: Quick search: search for two items at the same time
Can you show the _init function with the code and the _header -> tableview case as mentioned above.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Quick search: search for two items at the same time
Thanks, I tried again. The filter works but just add the code in the hook file of the corresponding table:
You don't need to add the other part of code.
Code: Select all
if (isset($_REQUEST['SearchString'])) {
$delimiter=' '; // change this if you want to use a different delimiter
$searchstring=$_REQUEST['SearchString'];
$QuerySearchableFields=array();
foreach($options->QueryFieldsQS as $fName => $fCaption)
if(stripos($fName, '<img') === false)
$QuerySearchableFields[$fName] = $fCaption;
$sssarray = explode($delimiter,makeSafe($searchstring)); // safe search stringarray
$options->QueryWhere = $options->QueryWhere ? $options->QueryWhere : " WHERE 1=1 ";
$s=array();
foreach($sssarray as $idx => $sss) {
if(count($QuerySearchableFields))
$s[]=implode(
" LIKE '%{$sss}%' OR ",
array_keys($QuerySearchableFields)
) . " LIKE '%{$sss}%'";
}
$options->QueryWhere.='AND ('.implode(' OR ',$s).' )';
$_REQUEST['NewSearch']=$searchstring;
$_REQUEST['SearchString']='';
}