SparseIndexHelper

Helpers for working with sparseIndex fields on records.

A sparseIndex is a number field that is used to sort records in a Store. It can have gaps and fractional values. SparseIndexes are unique among all records in a flat Store, i.e. no two records in a Store should have the same sparseIndex value. In case of a TreeStore, sparseIndexes are unique only among sibling records. The main purpose of a sparseIndex is to allow reordering of records without having to update the sparseIndex of every record in the Store. New records can be assigned a sparseIndex that is between the sparseIndexes of two existing records.

Properties

1
sorter: function

Sort function that can be used to sort records by their sparseIndex field, putting records without a sparseIndex at the end of the collection.

ParameterTypeDescription
aModel
bModel
Returns: number

Functions

1

Consolidates sparse indexes on the passed records, making them sequential numbers. Use this to avoid having duplicate values. IMPORTANT: Only use this on sorted records, otherwise it might create duplicate sparse indexes again!

ParameterTypeDescription
recordsModel[]
fieldNamestring