Sorter for the list binding This object defines the sort order for the list binding.
Method Summary
sap.ui.model.Sorter.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.Sorter with name sClassName
and enriches it with the information contained in oClassInfo
. getGroup(oContext)Returns a group object, at least containing a key property for group detection. Constructor Detail
new sap.ui.model.Sorter(sPath, bDescending?, vGroup?, fnComparator?)
Parameters:
{String} | sPath | the binding path used for sorting |
{boolean} | bDescending? | whether the sort order should be descending |
{boolean|function} | vGroup? | configure grouping of the content, can either be true to enable grouping based on the raw model property value, or a function which calculates the group value out of the context (e.g. oContext.getProperty("date").getYear() for year grouping). The control needs to implement the grouping behaviour for the aggregation which you want to group. In case a function is provided it must either return a primitive type value as the group key or an object containing a "key" property an may contain additional properties needed for group visualization. |
{function} | fnComparator? | a custom comparator function, which is used for clientside sorting instead of the default comparator method. |
Method Detail
sap.ui.model.Sorter.defaultComparator(a, b): int
Compares two values
This is the default comparator function used for clientside sorting, if no custom comparator is given in the constructor. It does compare just by using equal/less than/greater than with automatic type casting, except for null values, which are last in ascending order, and string values where localeCompare is used.
The comparator method returns -1, 0 or 1, depending on the order of the two items and is suitable to be used as a comparator method for Array.sort.
Parameters:
{any} | a | the first value to compare |
{any} | b | the second value to compare |
Returns:
{int} | -1, 0 or 1 depending on the compare result |
sap.ui.model.Sorter.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.model.Sorter with name
sClassName
and enriches it with the information contained in
oClassInfo
.
oClassInfo
might contain the same kind of information as described in sap.ui.base.Object.extend.
Parameters:
{string} | sClassName | Name of the class being created |
{object} | oClassInfo? | Object literal with information about the class |
{function} | FNMetaImpl? | Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata |
Returns:
{function} | Created class / constructor function |
Returns a metadata object for class sap.ui.model.Sorter.
Returns:
getGroup(oContext): object
Returns a group object, at least containing a key property for group detection. May contain additional properties as provided by a custom group function.
Parameters:
Returns:
{object} | An object containing a key property and optional custom properties |