Get Free Trial
API reference
Table of contents

sortFieldsList

sortFieldsList(compareFunction: Function)

[starting from version 2.9.17]

Sets custom sorting for Field List items.

sortFieldsList() can be defined in two ways:

  1. As a regular API call: flexmonster.sortFieldsList(compareFunction).
  2. As an initialization parameter: new Flexmonster({sortFieldsList: compareFunction, ...}).

Parameters

  • compareFunction — Function. Defines the sort order and works similarly to the compareFunction of the Array.sort() method.
    Data passed to the compareFunction:
    • firstItemFieldListItemObject. The first item for comparison.
    • secondItemFieldListItemObject. The second item for comparison.
    • viewType — String. The current view type. Can be one of the following values: "pivot", "flat", and "drillThrough".
    The compareFunction should return the positive, negative, or zero value.

Example

Sort Field List items in reverse alphabetical order:

flexmonster.sortFieldsList(function(firstItem, secondItem, viewType) {
	return secondItem.caption.localeCompare(firstItem.caption);
});

See the full code on JSFiddle.

See also

Custom sorting
sortingMethod()
setSort()
getSort()
sortValues()