All documentation
  • API Reference for older versions
  • 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: pivot.sortFieldsList(compareFunction).
    2. As an initialization parameter: new Flexmonster({sortFieldsList: compareFunction, ...}).

    Parameters

    The compareFunction function. Defines the sort order and works similarly to the compareFunction of the Array.sort() method. The compareFunction should return the positive, negative, or zero value.
    Data passed to the compareFunction:

    Parameter/TypeDescription
    firstItem
    FieldListItemObject
    The first item for comparison.
    secondItem
    FieldListItemObject
    The second item for comparison.
    viewType
    String
    The current view type. Can be one of the following values: "pivot", "flat", and "drillThrough".

    Example

    Sort Field List items in reverse alphabetical order:

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

    See the full code on JSFiddle.

    See also

    Sorting
    sortingMethod()
    setSort()
    getSort()
    sortValues()