- Are you just learning how to use IronPython in Spotfire?
- Would you like to be able to toggle between Filtering Schemes but are worried about users breaking something?
Filtering schemes are extremely useful for changing multiple filters at one time. However, if many users are working with a single file, it’s very easy for a single user to alter something that shouldn’t be altered. This is when I like to use a filtering scheme drop-down property control in conjunction with an Iron Python script to toggle between filtering schemes and have the filtering schemes be left alone.
Filtering Scheme Example
In the example shown in the video, I have three filtering schemes — Well Group A, Well Group B, Well Group C – that have different wells selected in the filter panel. The video will follow the steps shown below, using the code that is below the steps.
Instructions
- Create your filtering schemes.
- Add a text area to the page
- Toggle the text area into edit mode.
- Click the Add property control button and select drop-down list
- Click the New button to create a new property called FilteringSchemes using a string data type
- Select Fixed values in the Set property value through: drop down
- Under settings, in the Display Name, type – Julie’s wells, Amber’s wells, Kendra’s wells . This is what will show up in the drop down.
- Under Value, type – Well Group A, Well Group B, Well Group C. The case must match the filtering scheme exactly.
- Go to the FilteringScheme property, click the Script button.
- Set the radio button to Execute the script selected below:
- Click the New button and create a script called SchemeSelection
- Paste the script into the Script dialog
- Click the Add button and add a new Script Parameter MyFilterScheme.
- Note MyFilterScheme is part of the code that we just copied and pasted.
- Select String in the Type
- Set the radio button to Property and click the Select Property button
- Select the FilteringSchemes property just created
- Click OK
- Always click the Run Script button before exiting. That will tell you if the script is working. If you get errors, work through fixing. You may or may not be able to see the change if the script runs correctly, depending on what you have coded.
- Click OK, click OK and click OK
Here is a screenshot of the script so you can see what the spacing looks like.
Guest Spotfire blogger residing in Whitefish, MT. Working for SM Energy’s Advanced Analytics and Emerging Technology team!
Is there a way to set the drop down list with all the current Filtering Schemes programatically? The idea would be able to change and create filtering schemes from the text box rather than with the filtering tab, but I don’t want to have to create a drop down list manually every time.
I don’t believe you have access to that dropdown to programmatically add choices. One way you could achieve this is to use javascript to create your own dropdown and then push the changes to a text input, additionally salvaging the configuration you already have. I can try it in a blog this week but at a high-level:
1. create a ‘reset dropdown’ button that fires an ironpython. this ironpython sets a doc property to all the filterschemes concatenated
2. create a javascript that waits for that docprop.
3. whenever that docprop changes, it builds a custom dropdown with all those choices.
4. when the user makes a choices, jquery detects the blur() action and fires the original ironpython script.
Hi, is there a way of having an script that send a value to a dropdown (in a different view) in order to go to that page and with a filter value?
the use case will be: I have a table with the accounts and their high level metrics, I want to be able to click on an specific account and go to a different view (detailed) but filtered by the selected account (in this case the filter for the account its a dropdown
Can this be adapted so that the change of filtering scheme is applied to multiple tabs in the dxp rather than just the active tab?
How would the IronPython script need to be changed to do that?
It could be adapted for that purpose. You would need to add a parameter(s) that specifies the page(s) it should be applied to.
I tried this script and got an Error that “name “filteringSelection” is not defined” How do I fix this? Also, do you have any more detailed directions on how to implement what Steve Piper was wanting to do? I am needing this same thing, but I am very much a spotfire novice. Thanks!
“filteringSelection” is used in the 6th line of code. Are you sure that the bit in parenthesis after filteringSelection is spelled correctly and has the correct case? I would think this error could happen if it was misspelled and/or the parameter wasn’t setup. Do you have the parameter?
I have implemented the script and followed the instructions but for some reason when I select the second schema from the drop down the page continues to display the first filtering scheme only. Any idea why this would be happening?
Thank You
It sounds like one of the parameters or controls isn’t being recognized. When I worked with this code, I always had to be super careful about caps and plurals (or MyFilterScheme versus MyFilteringScheme). It was very easy to have a naming error. Consider changing some of the variable names to make it easier to QAQC.