Georgi Koemdzhiev
Georgi Koemdzhiev

Reputation: 11931

How to create a filtering scheme using Iron Python

Is it possible to create a new Filtering Scheme and set it to a page only using Iron Python? The reason why I am looking into that is because the Web Player currently does not allow us to create Filtering Schemes. I hope to achieve that by executing a script which will be triggered by a Document property change. The name of the filtering scheme will be passed from the JavaScript api my using SetDocumentProperty method.

The script below adds a new Filtering Scheme but I cannot select it from the Filtering Scheme menu in the Spotfire Analyst, it's nowhere to be seen. What am I missing?

from Spotfire.Dxp.Data import *
from Spotfire.Dxp.Application.Filters import *

Document.ActivePageReference.FilterPanel.Visible = True
# Add a new data filtering selection.
filterings = Document.Data.Filterings

filterings.Add("Test Filtering 1")

for f in filterings:
    print f.Name

enter image description here

I cannot see my newly added FilteringScheme after I ran the above script from the Filtering Scheme menu on the Analyst:

enter image description here

Upvotes: 0

Views: 1018

Answers (1)

Chelsea
Chelsea

Reputation: 511

The issue here is that "filterings" is a variable that you created, not an alias for the filter list -- you filled it with the data in the existing filters, but updating filterings afterwards does not update the filters on the page itself.

Change the code to this:

from Spotfire.Dxp.Data import *
from Spotfire.Dxp.Application.Filters import *

Document.ActivePageReference.FilterPanel.Visible = True
# Add a new data filtering selection.
Document.Data.Filterings.Add("Test Filtering 1")
filterings = Document.Data.Filterings

for f in filterings:
    print f.Name

Upvotes: 1

Related Questions