Jump to: navigation, search

Changes


HowTo:Implement Custom Filtering

2,121 bytes added, 09:38, 20 July 2023
/* Multiple Dynamic (User Inputs) Criteria */ Added an example of a boolean filter.
</tab>
</tabs>
<br>
The above example shows how to check for inputs to either property, NAME and DESCR, then use an additional EvalExpression to create the expression string that combines them. For each additional property you need to:
Once the additional input controls have been created, processed in their own EvalExpressions, referenced as EvalExpressionParameters and the "FilterExpression" EvalExpression has been adapted as shown, the filter should already function as required; the Collection Filters and Items Controls do not need to be adapted.
<br>
 
=== When One is a Boolean (CheckBox) ===
To process a Boolean filter, the expression needs to be slightly amended, due to the different type of filter match criteria that is required.
 
{{Attention|The below implementation returns all items by default (ie. when the CheckBox is unchecked), and returns only True matches when the CheckBox is checked. This functionality is designed to align with string input, where no filtering occurs for each string until something is entered into the corresponding text input box.}}
<br>
<source lang = "xml">
On UWP:
<controls:EvalExpression x:Name="Bool_FilterExpression" Expression="(INPUT==false) ? &quot;true==true&quot; : EXP" Context="{Binding}">
<controls:EvalExpressionParameter Name="EXP" Value="{Binding ElementName=CheckBox, Path=IsChecked, Converter={StaticResource StringFormatConverter}, ConverterParameter='Item.Values[&quot;MP_BOOL&quot;]==&quot;{0}&quot;'}" />
<controls:EvalExpressionParameter Name="INPUT" Value="{Binding ElementName=CheckBox, Path=IsChecked}" />
</controls:EvalExpression>
</source>
<br>
 
* The individual EvalExpression for a Boolean filter match needs to be amended as follows:
** The INPUT can never be null, as the IsChecked property is either True or False. Therefore we can remove the Null or empty test, and instead, check whether the CheckBox is checked or not. IsChecked=False should 'escape' the expression, and return all items (or, not contribute to the overall filtering).
* The EvalExpressionParameter 'EXP' similarly can be simplified, as it does not need to make a string match with .Contains, but simply check whether the property value matches to True or False.
<br>
Changed only need to be made to the individual EvalExpression. The "FilterExpression" that joins all individual expressions does not need to be amended, other than the regular additional EvalExpressionParameter, and updating the expression accordingly.
 
<br>
 
[[Category:Client|Custom Filtering]]
[[Category:Filtering|Custom Filtering]]
[[Category:Styling|Custom Filtering]]
[[Category:WinX|Custom Filtering]]
[[Category:Xamarin|Custom Filtering]]
 
== Combining Dynamic (User Inputs) and Static (Predefined) Criteria ==
A common use of the Collection Filter is to filter child lists based on one or multiple properties, such as MetaDefinition.UID or a certain status, to present groups of specific object types. Therefore, it is likely that a customizing may require hardcoded filter criteria, combined with user input, if any is provided.
487
edits