StoreGroup

Configs

2

Common

Initial groupers, specify to have store grouped automatically after initially setting data

Advanced

startGroupsCollapsed: Boolean= false

To have all groups initially loaded start collapsed, configure this as true.

Note that this only affects the initial load of the store. Subsequent reloads maintain current group state where possible.

Properties

5

Class hierarchy

isStoreGroup: Boolean= truereadonly
Identifies an object as an instance of StoreGroup class, or subclass thereof.
isStoreGroup: Boolean= truereadonlystatic
Identifies an object as an instance of StoreGroup class, or subclass thereof.

Other

Returns all the group header records

Sort, group & filter

Currently used groupers. To set groupers when remote sorting is enabled by sortParamName you should use setGroupers instead to be able to wait for the operation to finish.

isGrouped: Booleanreadonly

Is store currently grouped?

Functions

6

Removes all groupers, turning store grouping off.

Returns: Promise | null -

If sortParamName is set on store, this method returns Promise which is resolved after data is loaded from remote server, otherwise it returns null

Returns all records in the group with specified groupValue.

ParameterTypeDescription
groupValue*
Returns: Model[] -

Records in specified group or null if store not grouped

Get all group titles.

Returns: String[] -

Group titles

Group records, either by replacing current sorters or by adding to them. A grouper can specify a custom sorting function which will be called with arguments (recordA, recordB). Works in the same way as a standard array sorter, except that returning null triggers the stores normal sorting routine. Grouped store must always be sorted by the same field.

To clear groupers and stop grouping, use clearGroupers method.

// simple grouper
store.group('city');

// grouper as object, descending order
store.group({ field : 'city', ascending : false });

// using custom sorting function
store.group({
    field : 'city',
    fn : (recordA, recordB) => {
        // apply custom logic, for example:
        return recordA.city.length < recordB.city.length ? -1 : 1;
    }
});

// Stop grouping
store.clearGroupers();
ParameterTypeDescription
fieldString | Object

Field to group by. Can also be a config containing a field to group by and a custom sorting function called fn.

field.fieldString

Field to group by

field.fnfunction

Custom sorting function

field.ascendingBoolean

Sort order of the group titles

ascendingBoolean

Sort order of the group titles

addBoolean

Add a grouper (true) or use only this grouper (false)

performSortBoolean

Trigger sort directly, which does the actual grouping

silentBoolean

Set as true to not fire events

Returns: Promise | null -

If sortParamName is set on store, this method returns Promise which is resolved after data is loaded from remote server, otherwise it returns null

Check if a record belongs to a certain group (only for the first grouping level)

ParameterTypeDescription
recordModel

The Record

groupValue*

The group value

Returns: Boolean -

True if the record belongs to the group, otherwise false

Set groupers.

ParameterTypeDescription
groupersGrouper[]

Array of groupers to apply to store

Returns: Promise | null -

If sortParamName is set on store, this method returns Promise which is resolved after data is loaded from remote server, otherwise it returns null

Events

1

Fired when grouping changes

// Adding a listener using the "on" method
storeGroup.on('group', ({ source, groupers, records }) => {

});
ParameterTypeDescription
sourceStore

This Store

groupersGrouper[]

Applied groupers

recordsModel[]

Grouped records

Event handlers

1

Called when grouping changes

new StoreGroup({
    onGroup({ source, groupers, records }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

groupersGrouper[]

Applied groupers

recordsModel[]

Grouped records

Typedefs

1

An immutable object representing a store grouper.

ParameterTypeDescription
fieldString

Field name

ascendingBoolean

true to group ascending, false to group descending