Let's say you have a text area that you want to populate with filters, but you don't want to put too many filters in there, you just want the ones relevant to the user's area of interest.
You can create a dropdown where the user selects what they want to see, and a little python code will rebuild the text area to show only the filters that apply. For extra fun, we're going to use 3 different tables in our example dxp.
-
Create a text area containing all possible filters you will want. This is important because here you will establish all of the Spotfire control ids to be used later. If you miss a filter its gonna suck so better to have too many than too few. Edit the html and put a <div> tag before each filter and a </div> tag at the end of each filter (see example dxp).
-
Create a doc property dropdown. This will store the possible values that wll drive the different filter configurations. When changed it wil trigger a script that rebuilds the text area containing the filters.
-
Time for python. Add a script triggered by a change in the doc property from step 2 (Edit-->Document properties. Select Properties tab, click on property created in Step 2, click the scrips button, click 'execute the script selected below, click 'New')
The script name is whatever you want to call it. Would suggest a company naming convention but that's just me.
Here's the script
# Start
from Spotfire.Dxp.Application.Visuals import VisualContent
ta=vTextArea.As[VisualContent]()
ta.HtmlContent = myContent
# End
Script parameters to add
vTextArea= type: visualization then pick the text area created in step 1 with all of the filters
myContent=type:string then click 'expression' and click 'edit expression'
this expression is a case statement whose results are always the full html from the text area. The trick is to change the <div> tag on filters you DONT want to see to <div style='display:none'>
See the example dxp for more details here. You'll have to change the html to match your spotfire control ids. Also you can swap the order of filters around if you want, but always include the full html with all spotfire control ids.
Download the file example.dxp, for an example to address this issue.
DISCLAIMER: The great thing about Spotfire is you can accomplish the same goal 10 different ways, the bad thing is the people who did it the other 9 ways will say your method is wrong.
Recommended Comments
There are no comments to display.