I have learnt how to write neatly when applying Filter to a gallery, and I have made notes on how I have tried and tested filtering and the problems I have had with it.
Advance preparation
If the combo box for an element is empty, it is not filtered for that element.
*To simplify the example, all combo boxes should be singular selections only (no multiple selections).
Trial and error 1: large number of if functions
*It’s hard to write, so this time I gave up with two If functions.
but the problem is low readability and poor maintenance.
It is hard to create if statements because they keep increasing, and it is hard to modify the code because similar expressions need to be written in various places.
Trial and error 2: Assignments to variables
The next method considered was to clean up the expression by assigning the result of the Filter expression to a variable.
It is also highly readable, easy to modify the code and was once thought to be a good method.
However, once again, there are problems with this method, large and small, but the main problem is that it is caught by the ‘data row limit’.
Once assigned to a variable, the gallery read function cannot be used, and when targeting a data source with a large number of records, only 500 data can be displayed (by default).
Best practice: use the Filter function’s method of determining logical expressions wisely.
Based on these, the method learned this time is how to make good use of the Filter function’s logical expressions.
In fact, the logical expressions after the second argument of the Filter function do not necessarily refer to the value of the data source.
The specification of the Filter function is that if the logical expression is evaluated for a row (record) and the result is ‘true’, the row is retrieved.
For example, if no user is selected in UserCombobox_2 (if IsBlank(UserCombobBox_2.Selected) is true), the expression to the right of or (|| UserComboBox_2.Selected.Mail = User.Email) not evaluated and all rows will evaluate to true, so all rows will break through this logical expression.
Using this method, it is possible to write an expression that says that if the value of the control is empty, it will not be filtered, using only the Filter function, which is a much cleaner expression.
Furthermore, since the data source is specified directly in the gallery, there is no need to worry about ‘data row limits’.
*Of course, write it in such a way that you don’t get any delegation warnings.
コメント