<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div>
<h2>How to sort multiple columns in the flat view at runtime</h2>
<p>
In the flat view, you can sort multiple columns either via UI or
programmatically.
</p>
<p>
To sort multiple columns via UI, press <code>Ctrl</code>
(<code>Command</code> on macOS) and click a sorting arrow on each
column to be sorted.
</p>
<p>
To sort multiple columns programmatically, use the
<a href="https://www.flexmonster.com/api/setflatsort/" target="_blank"
>setFlatSort()</a
> method. It's also possible to preset sorting in the report using the
<a
href="https://www.flexmonster.com/api/slice-object/#flatSort"
target="_blank"
>slice.flatSort</a
> property.
</p>
<p>
In the example below, we sort the <code>Category</code> and <code>Price</code> fields.
</p>
<p>
Click the <b>Get Flat Sorting</b> button to output sorting for the flat view
under the component.
</p>
<p>
<a href="https://www.flexmonster.com/doc/slice/" target="_blank"
>Visit our docs to learn more about configuring the slice</a>.
</p>
</div>
<button onclick="setSort()">Set flat sorting</button>
<button onclick="removeSort()">Remove flat sorting</button>
<button onclick="getSort()">Get flat sorting</button>
<div id="pivot-container"></div>
<div class="output" id="output">Output will appear here</div>