Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

How to control/filter a list of values for EnumProperty
xomega
#1 Posted : Saturday, October 20, 2012 6:58:39 PM(UTC)
xomega



Enumeration properties in the Xomega Framework provide default filtering of the Header objects for the possible values to exclude inactive ones (that are used for looking up items for existing values, but not for selecting in lists anymore), and to implement any cascading selection that is configured for the property.

You can, however, implement your own filter function and assign it to the FilterFunc member of the enumeration property. The filter function accepts a Header object as a parameter and returns a true boolean value, if it matches the filter, and false otherwise. You can use the ID or a Text of the Header to filter individual items, or you can use the values of additional attributes to filter certain categories of the items. You can also invoke the default function IsAllowed to add your filtering on top of the default behavior.

The following example shows how an operator property is assigned a custom filter function implemented as a lambda expression, which invokes the default filtering function first, and then checks if the value of the multivalue additional attribute, whose name is specified by a constant string, is equal to "1".
Code:
MyOperatorProperty.FilterFunc = hdr => MyOperatorProperty.IsAllowed(hdr) && 
    hdr[Enumerations.Operators.Attributes.Multival] == "1";
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.