#

API Docs for: 3.10.3
Show: Inherited Protected Private Deprecated

# RecordsetSort Class

Defined in: `recordset/js/recordset-sort.js:10`
Module: recordset-sort
Parent Module: recordset

Plugin that adds default and custom sorting functionality to the Recordset utility

- Index
- Methods
- Attributes

## Item Index

### Methods

- _defSortFn
- flip
- initializer
- resort
- reverse
- sort

### Attributes

- defaultSorter
- defaultSorter
- lastSortProperties

## Methods

### `_defSortFn`

() private

Defined in `recordset/js/recordset-sort.js:119`

Method that all sort calls go through. Sets up the lastSortProperties object with the details of the sort, and passes in parameters to the "defaultSorter" or a custom specified sort function.

### `flip`

() public

Defined in `recordset/js/recordset-sort.js:177`

Sorts the recordset based on the last-used sort parameters, but flips the order. (ie: Descending becomes ascending, and vice versa).

### `initializer`

() protected

Defined in `recordset/js/recordset-sort.js:80`

Sets up the default function to use when the "sort" event is fired.

### `resort`

() public

Defined in `recordset/js/recordset-sort.js:152`

Resorts the recordset based on the last-used sort parameters (stored in 'lastSortProperties' ATTR)

### `reverse`

() public

Defined in `recordset/js/recordset-sort.js:167`

Reverses the recordset calling the standard array.reverse() method.

### `sort`

(

- `field`
- `desc`

)
public

Defined in `recordset/js/recordset-sort.js:136`

Sorts the recordset.

#### Parameters:

- `field` String

  A key to sort by.

- `desc` Boolean

  True if you want sort order to be descending, false if you want sort order to be ascending

## Attributes

### `defaultSorter`

Function public

Defined in `recordset/js/recordset-sort.js:44`

Default sort function to use if none is specified by the user. Takes two records, the key to sort by, and whether sorting direction is descending or not (boolean). If two records have the same value for a given key, the ID is used as the tie-breaker.

#### Fires event `defaultSorterChange`

Fires when the value for the configuration attribute `defaultSorter` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

#### Parameters:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.

### `defaultSorter`

Function public

Defined in `recordset/js/recordset-sort.js:65`

A boolean telling if the recordset is in a sorted state.

#### Fires event `defaultSorterChange`

Fires when the value for the configuration attribute `defaultSorter` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

#### Parameters:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.

### `lastSortProperties`

Object public

Defined in `recordset/js/recordset-sort.js:26`

The last properties used to sort. Consists of an object literal with the keys "field", "desc", and "sorter"

#### Fires event `lastSortPropertiesChange`

Fires when the value for the configuration attribute `lastSortProperties` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.

#### Parameters:

- `e` EventFacade
  An Event Facade object with the following attribute-specific properties added:
  - `prevVal` Any
    The value of the attribute, prior to it being set.
  - `newVal` Any
    The value the attribute is to be set to.
  - `attrName` String
    The name of the attribute being set.
  - `subAttrName` String
    If setting a property within the attribute's value, the name of the sub-attribute property being set.