Search code examples
widthvisualizationspotfire

Spotfire Table Visualization column width


Is there a way to set Spotfire Table visualization column width either through Java or Python script. i can able to change the column width manually but whenever the value changes through property control it reset again. I need to set constant column width. Thanks in advance.


Solution

  • good question! you can add an IronPython script (I don't believe it's possible to do this using Javascript unless you are some kind of wizard, or otherwise hate yourself :) to do this pretty simply.

    I'll put the examples all in one code snippet, but obviously you would only want to do one of these loops at a time. the snippet expects a parameter called viz whose value is the TablePlot visualization you wish to modify.

    from Spotfire.Dxp.Application.Visuals import TablePlot
    
    v = viz.As[TablePlot]()
    
    # increase all column widths by 10 pixels
    for col in v.Columns:
        col.Width = col.Width + 10
    
    
    # set all column widths to 100 pixels (the default value)
    for col in v.Columns:
        col.Width = 100
    
    
    # set the width of a specific column to 50 pixels
    for col in v.Columns:
        if col.Name == "My Column":
            col.Width = 50