findFirst, findAll (Find values in lists)
See also: contains
Allows searching one or more values in a list or data provider.
►NOTE◄ If the source is a data provider, only the already loaded entries can be searched. No server side searches are performed!
Syntax
$findFirst(source,boolExpression)
$findAll(source,boolExpression)
Parameter
|
Name |
Description |
|
source |
The list or data provider to be searched. |
|
boolExpression |
An expression which is called for each entry in source. The input object ($input) is the respective entry. Tip: The variable "orgInput" (accessible via $var(orgInput)) contains the original input object at the level of the $findXXX function. |
Return value
In the case of $findFirst, the entry that was the first to match the search constraint is returned.
In the case of $findAll, a list of all entries that match the search constraint is returned.
Examples
For the examples, $input is assumed to be a list of tuples of the following format:
[ { "key": "1", "label": "Item 1", "value": 220 }, { "key": "2", "label": "Item 2", "value": 95 }, { "key": "3", "label": "Item 3", "value": 100 }, { "key": "4", "label": "Item 4", "value": 10 }, { "key": "5", "label": "Item 5", "value": 5 }]|
Expression |
Result |
Effect |
|
$findFirst($input,$cmp({key},=,4)) |
Entry "Item 4" |
Returns an entry whose field "key" has the value 4. |
|
$findAll($input,$cmp({value},>=,100,n)) |
List with "Item1" and "Item 3 |
Returns all entries of the list whose field "value" has a value greater or equal 100. |
|
$findFirst($el(8,true),$cmp({value},=,$var(orgInput))) |
The entry whose value field corresponds to the original input value |
$el(8,true) returns all values of all repetitions of the element with ID 8. $var(orgInput) returns the original input value at the level of the $findFirst function. |