dataSource.CollectionSearch Class
Class created dynamically by dataSource.Collection. It is used to search and filter data in a collection.
Item Index
Methods
Events
Methods
and
-
search
AND search
Returns:
Example:
var searcher = myDataSource.getSearcher();
var populationFn = function(record){
return record.population > 1000000 ? true: false;
}
searcher.where('Europe').and(populationFn).execute();
Finds all records where 'Europe' is in the text and population is greater than 1 million.
branch
()
endBranch.CollectionSearch
chainable
Close group of search items.
Returns:
deleteSearch
()
Delete search terms/functions and dispose search result. This method will fire a deleteSearch event which dataSource.Collection listens to. It will trigger an update of views using the dataSource.Collection object as dataSource.
execute
()
dataSource.CollectionSearch
chainable
Execute a search based on current search terms
Returns:
Example:
// Assumes that ludo.get('collection') returns a dataSource.Collection object
var searcher = ludo.get('collection').getSearcher();
searcher.clear();
searcher.where('Oslo').or('Moscow');
searcher.execute();
hasData
()
Boolean
Returns true when
- zero or more records are found in search result
Returns false when
- search result is undefined because no search has been executed or search has been deleted.
Returns:
or
-
search
OR search
Returns:
Example:
var searcher = myDataSource.getSearcher();
var populationFn = function(record){
return record.population > 1000000 ? true: false;
}
searcher.where('Europe').or(populationFn).execute();
Finds all records where 'Europe' is in the text or population is greater than 1 million.
where
-
search
Start building a new search
Returns:
Example:
var searcher = ludo.get('idOfDataSearch').getSearcher();
searcher.where('Portugal').or('Norway').execute();
will find all records where the search index matches 'Portugal' or 'Norway' (case insensitive). By default, the entire record is indexed. Custom indexes can be created by defining index using the "index" constructor attribute.
searcher.where(function(record){
return parseInt(record.price) < 100
});
is example of a function search. On dataSource.Collection/execute this function will be called for each record. It should return true if match is found, false otherwise. The function above will return true for all records where the value of record.price is less than 100.
withIn
-
searches
Search for match in one of the items
Parameters:
-
searches
Array
Returns:
Attributes
delay
Number
Delay in seconds between call to search and execution of search. A delay is useful when using text fields to search.
Default: 0
Example:
delay:0
Events
deleteSearch
Search executed without any search terms
search
Search executed