sortFieldsList(compareFunction: Function)
[starting from version 2.9.17]
Sets custom sorting for Field List items.
sortFieldsList()
can be defined in two ways:
pivot.sortFieldsList(compareFunction)
.new Flexmonster({sortFieldsList: compareFunction, ...})
.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/Type | Description |
---|---|
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" . |
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.