Swap columns' sorting priorities in the flat view

Slice configuration

by Flexmonster Pivot Table

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<button onclick="swap()">Swap sorting priorities</button>

<div id="pivot-container"></div>

CSS

@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);

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 = pivot.getFlatSort();
  flatSort.reverse();
  pivot.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":...