Jump to content

Please let me know if you have a python sample that hides or shows a specific column in a datatable on that page by clicking a button in a textarea.


Min Su Sun

Recommended Posts

Hello,

I assume that what you are trying to do is to show/hide a column in a table plot (if not, please clarify). I'm not aware of any way to explicitly hide it but here are two examples where I tested first adding/removing it, and then setting the width to hide/show it.

from Spotfire.Dxp.Application.Visuals import *
 
#columnToToggle = Document.Properties["propTableColumnName"]
columnToToggle = "Year"
#vis is a script parameter for my table plot
tablePlot = vis.As[TablePlot]() 
tableColumns = tablePlot.TableColumns
tableDataColumns = tablePlot.Data.DataTableReference.Columns
dataColumnToToggle = tableDataColumns[columnToToggle]
 
#Check if data column exists in collection
columnExists = tableColumns.Contains(dataColumnToToggle)
 
if(columnExists):
	print "Exists. Remove it."
	tableColumns.Remove(dataColumnToToggle)
else:
	print "Does not exist. Add it."
	tableColumns.Add(dataColumnToToggle)
from Spotfire.Dxp.Application.Visuals import *
 
#columnToToggle = Document.Properties["propTableColumnName"]
columnToToggle = "Year"
#vis is a script parameter for my table plot
tablePlot = vis.As[TablePlot]() 
tableColumns = tablePlot.TableColumns
tableDataColumns = tablePlot.Data.DataTableReference.Columns
dataColumnToToggle = tableDataColumns[columnToToggle]
 
tableColumn = tableColumns.TryGetTableColumn(dataColumnToToggle)[1]
 
if(tableColumn.Width < 10):
	tableColumn.Width = 100
else
	tableColumn.Width = 0

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...