I should do a filter on a query using two fields.
One is a text field (“testofrm”), the other is a select that passes a numeric value (“odcfrm”). If I use both of them (the value from select and then I write a text), it works.
But I would like it to pass the value “all” by default so that I can search a text without using menu or search only through the drop-down menu
Have a look at creating groups in your query, and then use the Toggle Condition (?) to create an expression that when true will include that group in the query, and when false, the group will be ignored.
For example the following is a group that searches country_name, but only if the search_text GET var is provided.
With groups you can likely change your strategy so that the value ‘all’ is no longer needed, but even if it is, you can use it in the toggle condition.
In the conditions, just specify the appropriate fields. This will mean that a group with a filter will only work if the field contains data. If the field is empty, the filter group will not work.
If I understand you correctly, this will do exactly what you need.
I still have a problem, how do I get the first value in the menu (select all) to be “all”? Values are numeric. Now I have written% but I know it is wrong
Well, combining two functions in one select (a separate selection and the selection of all values at once) requires a different, more complex approach.
The most rational solution that comes to mind is as follows:
To get all the values in the input without overloading the client part with unnecessary actions, you will need to slightly supplement the server action, which is responsible for supplying values for the select. You will need to add another Set Value step with all the values that you use in the select combined into a string. It looks like this:
After that, you will have to redo your “odcfrm " filter. Because in it you use equal, which works as a strict equality and will not work in the case of the “select all” option. For the filter to work correctly, you need to change the condition from equal to in, and specify the following values in the value: {{$_GET.odcfrm. split(",")}}
Why do you have mixed up the filtering conditions in places? Where contains{{$_GET.testform}} is used, the conditions must contain {{$_GET.testform}}. And in the group with in{{$_GET.odcfrm.split(",")}} in the conditions should be {{$_GET.odcfrm}}. In this case, everything should work correctly.
Not sure if i am more confused than by exactly are you trying to achieve or the replies you got here.
So can we start from the beginning?
What i understand is - you have a text field and a select menu.
My question is - how do you want to use them to filter your query? So - when nothing is selected in the select menu, or entered in the text field - show all?
And then - how should the two fields work? Separately? Or do you always expect to have values in both?
Should the user be able to filter the data using any of the two fields and also both together?
I should be able to use the two search filters separately, but if one of them is not used it must have the value “all” (both the menu and the text field).
Let me explain:
the user must be able to search for the name of a company (by text) or the type to which it belongs (with the drop-down menu, which gives the query a numerical value)
If the user searches only for the type, the text will necessarily be “all”.
If the user searches for the text, the type will necessarily be “all”
Some explanation here, the ? icon represents a condition - i.e. where should the filter be applied. In your case there you bind the same as selected for the filter values. I.e. when the input has a value, then this filter will be applied, otherwise it will show all the records.
Make sure to select OR, as when AND is used, then the two inputs are always required and in your case you need to be able to use them separately.
And finally on your page, bind the two inputs value to the server connect component:
Apologize. I misunderstood your original task. The solution that I proposed is aimed at the ability to filter both by individual fields, and create a cross-search. As it turned out, you needed a simpler solution in the form of the ability to search for individual fields.