Sorting

These IronPython scripts below show how to modify any of the Table visualization settings found on the Sorting tab of the Table Properties dialog box in the Spotfire user interface.
Note

In each of the scripts below, it is assumed that the MyVis variable references the targeted visualization. See here for more information about referencing visualizations.

Change Table Sorting Tab Options:

To change the sort order of a table plot, it is easiest to clear all the sorting info first, then rebuild the column sorting order from scratch, as shown below. It’s also important to note that only columns shown in the table plot (as set on the Columns tab) can be used for sorting.

from Spotfire.Dxp.Application.Visuals import *

myVis = myVis.As[Visualization]()
dataTable = myVis.Data.DataTableReference

# Clear any existing sort order information
myVis.SortInfos.Clear()

# Add sort order info based on data table column names
# The order added below determines the order that columns influence the sort
myVis.SortInfos.Add(dataTable.Columns.Item["Column 1"], TablePlotColumnSortMode.Ascending)
myVis.SortInfos.Add(dataTable.Columns.Item["Column 2"], TablePlotColumnSortMode.Descending)
myVis.SortInfos.Add(dataTable.Columns.Item["Column 3"], TablePlotColumnSortMode.Ascending)
Welcome!

The purpose of this website is to provide a comprehensive, accurate, and efficient IronPython reference for Spotfire developers.

If you have any questions, comments, or ideas, feel free to get in touch!