Jump to content
  • How to add a new Column Property in Spotfire® using IronPython Scripting


    How to add a new Column Property in TIBCO Spotfire® using IronPython Scripting

    Introduction

    This article gives a code sample to add a new Column Property in an analysis file. Refer to the attached analysis file for your reference.

    Code Sample

    # Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    from Spotfire.Dxp.Data import DataProperty, DataType, DataPropertyAttributes, DataPropertyClass
    
    #use any column which can be referenced while checking if the column property to be created already exists or not
    table=Document.Data.Tables["tableName"]
    column=table.Columns["columnName"]
    
    #the variable columnProperty takes the value from the input field
    
    if (column.Properties.PropertyExists(columnProperty) == False): #checks if that column property alread exists or not
        myProp = DataProperty.CreateCustomPrototype(columnProperty,0,DataType.Integer,DataPropertyAttributes.IsVisible|DataPropertyAttributes.IsEditable) #creates a prototype of a property
        Document.Data.Properties.AddProperty(DataPropertyClass.Column, myProp) #creates a new coloumn property
    
    #Prototype of CreateCustomPrototype method used here
    #CreateCustomPrototype(String, Object, DataType, DataPropertyAttributes)
    #String is the name of the property and Object is its default value 
    
    # Set the value of a column property to 123 of [columnName] COLUMN
    #column.Properties.SetProperty(columnProperty,123)
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...