Open vladiibine opened 9 years ago
Yes, adding the ability to have AND or OR would make it way more flexible but it would also need parenthesis. This is a more complex UX pattern. I'm not sure which direction I want to go with this project (easier but more limited or flexible but more complex). I'll think about it.
My solution (with php):
structured-filter.js
var evoLang={sYada:'Multi'}
//--
evoAPI={sYada:'yada'}
//--
default:
EvoUI.inputOption(evoAPI.sYada, evoLang.sYada);
custom.php
if ($operator=="yada"){
$gelen_degerler=explode(",",$search_values);
$numItems = count($gelen_degerler);
$yada_i = 0;
$filtre_degerim=" and (";
foreach($gelen_degerler as $deger)
{
$filtre_degerim.=' f'.$i.'.deger like "%' . $deger.'%" ';
if(++$yada_i === $numItems)
$filtre_degerim.= ') ';
else
$filtre_degerim.= ' or ';
}
$additional_where = $filtre_degerim;
}
$sql="Select * from table where salary=1000 ".$additional_where;
Usage : Select "multi" options and type values with comma. Like "name1,name2"
+1 for operators between conditions.
+1 for operators
:+1:
:+1:
👍 + for operators
I think this is a strong library as-is - without the complexity of boolean logic and parenthesis. This keeps the implementation and UX much simpler, while meeting the needs for many use cases.
See https://querybuilder.js.org/ if you need to handle more complex use cases.
It would be awesome if I could do filtering like this: { {Username contains 'asdf' AND Lastname contains 'foo'} OR {Username startswith 'A' and age < 13} }
This way a lot more flexible queries could be built