structured-filter icon indicating copy to clipboard operation
structured-filter copied to clipboard

Custom OR logic?

Open vladiibine opened this issue 10 years ago • 8 comments

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

vladiibine avatar Oct 31 '15 08:10 vladiibine

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.

evoluteur avatar Nov 22 '15 11:11 evoluteur

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"

mehkar avatar Dec 29 '15 13:12 mehkar

+1 for operators between conditions.

andreas83 avatar Jul 28 '16 06:07 andreas83

+1 for operators

jerodfritz avatar Aug 11 '16 13:08 jerodfritz

:+1:

ruden avatar Oct 25 '16 09:10 ruden

:+1:

aurora avatar Jul 23 '17 08:07 aurora

👍 + for operators

phmulin avatar Sep 05 '20 04:09 phmulin

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.

jasonhildebrand avatar Jul 27 '21 15:07 jasonhildebrand