PredefinedGroup
Description
A PredefinedGroup is an interface that represents a static group with well-known properties.
Properties
|
Property |
Type |
Description |
|---|---|---|
|
value |
any |
The value representing the group. |
|
filterDescription? |
The filter description used to figure out the data items contained in the group. |
|
|
predicate? |
function(item : |
A predicate function used to figure out the data items contained in the group. |
Examples
Example 1
The following example defines a PredefinedGroup that targets countries located in North America using a predicate.
const northAmerica = {
value: "North America",
predicate: item => (item.country === "Canada") || (item.country === "Mexico") || (item.country === "USA")
};
Example 2
The following example defines a few PredefinedGroup based on a rating using a FilterDescription.
const excellent = {
value: "Excellent",
filterDescription: {
field: "rating",
operatorKey: "gt",
operand: 3
}
};
const medium = {
value: "Medium",
filterDescription: {
field: "rating",
operatorKey: "eq",
operand: 3
}
};
const poor = {
value: "Poor",
filterDescription: {
field: "rating",
operatorKey: "lt",
operand: 3
}
};
Remarks
A PredefinedGroup can be provided through a GroupConfiguration.
A PredefinedGroup offers 2 ways to specify the data items contained in the group. Either it provides a FilterDescription on the filterDescription property or it provides a predicate on the predicate property. Only one of these properties must be set.
A predicate is more powerful than a FilterDescription since it can reference anything the JavaScript language provides while a FilterDescription has access to a limited set of filter operators. However, since a predicate is a function with actual code, some data provider may not be able to deal with them. For example, a data provider that sends queries to a web service will not be able to run the predicate remotely while it could be able to parse a FilterDescription and convert it in a way to let the web service do the filtering remotely.