Swapping sorting priorities in flat table multi-column sorting
Slice configuration
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<link rel="stylesheet" type="text/css" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<button onclick="swap()">Swap sorting priorities</button>
<div id="pivot-container"></div>
JavaScript
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 600,
toolbar: true,
report: {
dataSource: {
data: getData()
},
slice: {
rows: [
{uniqueName: "Category"},
],
columns: [
{uniqueName: "[Measures]"}
],
measures: [
{uniqueName: "Price", aggregation: "sum"},
],
flatSort: [
{
uniqueName: "Category",
sort: "asc"
},
{
uniqueName: "Price",
sort: "asc"
}
]
},
options: {
grid: {
type: "flat"
}
}
}
});
function swap() {
var flatSort = flexmonster.getFlatSort();
flatSort.reverse();
flexmonster.setFlatSort(flatSort);
}
function getData() {
return [
{
"Color": { "type": "string" },
"M": {
"type": "month",
"dimensionUniqueName": "Days",
"dimensionCaption": "Days",
"caption": "Month"
},
"W": {
"type": "weekday",
"dimensionUniqueName": "Days",
"dimensionCaption": "Days",
"caption": "Week Day"
},
"Country": {
"type": "level",
"hierarchy": "Geography",
"level": "Country"
},
"State": {
"type": "level",
"hierarchy": "Geography",
"level": "State",
"parent": "Country"
},
"City": {
"type": "level",
"hierarchy": "Geography",
"parent": "State"
},
"Price": 0,
"Quantity": { "type": "number" },
"Discount": { "type": "number" },
"Category": { "type": "string" },
"Business Type": { "type": "string" }
},
{
"Color": "green",
"M": "September",
"W": "Wed",
"Country": "Canada",
"State": "Ontario",
"City": "Toronto",
"Price": 174,
"Quantity": 22,
"Discount": 23,
"Category": "Accessories",
"Business Type": "Specialty Bike...