Change Cross Table properties

#Script to change row header, cell widths and row sorting
#viz is a Cross Table visualization script parameter
from Spotfire.Dxp.Application.Visuals import CrossTablePlot, CategoryKey 

from Spotfire.Dxp.Data import SortOrder 

#Get a reference of the cross table from viz param
crossTable = viz.As[CrossTablePlot]()

#Change the second RowHeader
crossTable.RowHeaderWidths[1]=150

#Resize cells
crossTable.CellWidth=100

#Change sorting
categoryKey = CategoryKey("cellValueColumnToSort") 
crossTable.SortRowsCategory = categoryKey 
crossTable.SortColumnsOrder = SortOrder.Descending

See CrossTablePlot Members


1 comment:

Mohanvel Rajendran said...

Hi,

I have applied the same script below where i need to sort column "RefrenceDate_Month" but it is not getting sorted

#Script to change row header, cell widths and row sorting
#viz is a Cross Table visualization script parameter
from Spotfire.Dxp.Application.Visuals import CrossTablePlot, CategoryKey

from Spotfire.Dxp.Data import SortOrder

#Get a reference of the cross table from viz param
crossTable = viz.As[CrossTablePlot]()

#Change the second RowHeader
crossTable.RowHeaderWidths[1]=150

#Resize cells
crossTable.CellWidth=100

#Change sorting
categoryKey = CategoryKey("RefrenceDate_Month")
crossTable.SortRowsCategory = categoryKey
crossTable.SortColumnsOrder = SortOrder.Descending