useSorting
useSorting
provides getter and setter for sorting results.
Usage
setSorting
expects a string, and that string must satisfy the following requirements:
- There must be at least one record in the collection that has that field and its corresponding value.
- The field's value must be an
Integer
,Float
,Timestamp
or aString
. - It must follow the syntax of
"${field}"
for ascending order of that field and"-${field}"
for the opposite
E.g. if your record contains a rating
field, then passing "rating"
to sort for items that have the lowest rating to highest, or "-rating"
for highest to lowest.
Editable Example
​
Suggestions
Loading...
Anatomy
useSorting
returns an object containing the following properties:
Name | Type | Default | Description |
---|---|---|---|
sorting | sorting | The currently sorting mode. | |
setSorting | (order: string, runSearch?: boolean) => void | Method to set sorting mode. |
Parameters
Name | Type | Default | Description |
---|---|---|---|
order | string | The value for sorting results. | |
runSearch | boolean | true | Whether to perform a search afterwards. |