Labels

Show current filter settings


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from Spotfire.Dxp.Application.Visuals import VisualContent
from System import Guid

page = Application.Document.ActivePageReference

#Get the filtering scheme used on this page
filteringSchemeRef = page.FilterPanel.FilteringSchemeReference

#Get the name of the filtering scheme on the active page
for filteringScheme in Document.FilteringSchemes:
 filteringSelection = filteringScheme.FilteringSelectionReference
 if filteringScheme == filteringSchemeRef: 
  filteringSchemeName = filteringSelection.Name

content="<STRONG>Filtering Scheme:</STRONG> " + filteringSchemeName

filterPanel = page.FilterPanel
filterPanel.InteractiveSearchPattern = "status:m"

for filters in filterPanel.FiltersMatchingSearchPattern:
 print filters.FilterReference.ToString()

for tableGroup in filterPanel.TableGroups :
 print tableGroup.ToString()
 tableGroup.Expanded=True
 for filterGroup in tableGroup.SubGroups :
  print filterGroup.ToString()
  print filterGroup.Expanded
  filterGroup.Visible=False
  if (filterGroup.Expanded == False):
      filterGroup.Expanded = True
  else:
   filterGroup.Expanded = False

for tableGroup in filterPanel.TableGroups:
 isMod=0
 str="<p>"
 if filterPanel.TableGroups.Count > 1:
  str+="<b>"+tableGroup.FilterCollectionReference.DataTableReference.Name+":</b><br>"
 for fh in tableGroup.FilterHandles:
  if fh.FilterReference.Modified:
   isMod=-1
   str+=fh.FilterReference.ToString()
   str+="<br>"
 for subGroup in tableGroup.SubGroups:
  for fh in subGroup.FilterHandles:
   if fh.FilterReference.Modified:
    isMod=-1
    str+=fh.FilterReference.ToString()
    str+="<br>"
 str+="</p>"
 if isMod==-1:
  content+=str  

ta=vTextArea.As[VisualContent]()
if(ta.HtmlContent is None):
 ta.HtmlContent = " "

if (ta.HtmlContent.find("<SPAN id=fs>")==-1):
  ta.HtmlContent=="<SPAN id=fs>"+ta.HtmlContent
final=ta.HtmlContent.split("<SPAN id=fs>")[0]+"<SPAN id=fs>"+content+"</SPAN>"
ta.HtmlContent=final

#Reset filter panel search and navigate to the Filter Settings Page
filterPanel.InteractiveSearchPattern = ""

Input:
vTextArea (Text Area): The text area that will be modified to show the current filter settings.

This script will list the modified filters for the current page, and how they have been modified.  The output will be generated in HTML format and inserted into the specified text area.  Here is a sample of the output:



Here is a similar variation that also is compatible with in-database connections:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from Spotfire.Dxp.Application.Visuals import VisualContent
from System import Guid

page = Application.Document.ActivePageReference


#Get the filtering scheme used on this page
filteringSchemeRef = page.FilterPanel.FilteringSchemeReference

filterPanel = page.FilterPanel

#Now set the filtering scheme to that of the originating page
filterPanel.FilteringSchemeReference = filteringSchemeRef

for filteringScheme in Document.FilteringSchemes:
 filteringSelection = filteringScheme.FilteringSelectionReference
 if filteringScheme == filteringSchemeRef: 
  filteringSchemeName = filteringSelection.Name

content="<STRONG>Filtering Scheme:</STRONG> " + filteringSchemeName + "<BR><BR>"

filterPanel.InteractiveSearchPattern = "status:m"
for filters in filterPanel.FiltersMatchingSearchPattern:
 content += filters.FilterReference.ToString() + "<BR>"


ta=vTextArea.As[VisualContent]()
if(ta.HtmlContent is None):
 ta.HtmlContent = " "

if (ta.HtmlContent.find("<SPAN id=fs>")==-1):
  ta.HtmlContent=="<SPAN id=fs>"+ta.HtmlContent
final=ta.HtmlContent.split("<SPAN id=fs>")[0]+"<SPAN id=fs>"+content+"</SPAN>"
ta.HtmlContent=final

filterPanel.InteractiveSearchPattern = ""

23 comments:

  1. Great script! How can I get it to refresh whenever filter criteria changes. Currently I have it as a button script.
    Thanks!

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Team how to refresh the filter values after running this script?

    ReplyDelete
  5. This is not working for range filters like date

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. To get it to work for a range filter I simply added the following code below, putting it on line 54 in the first code example or line 25 in the second code example above:

    # added the "replace" method below to fix the previous HTML error displaying an "="
    content = content.replace("<=","&#60;&#61;")

    I call the code from a hidden Action Control button in a text area (which also contains my filters), using the Javascript below to call the script with a "setInterval" timer:

    $(function() {
    setInterval(
    function()
    {
    $("#load :first-child").click();
    }, 1000);
    });

    As I change my filters the text area updates with my current filter settings.

    Dave R
    Cadeon

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  9. I am new to spotfire scripting and receiving the following error:
    Traceback (most recent call last):
    File "Spotfire.Dxp.Application.ScriptSupport", line unknown, in ExecuteForDebugging
    File "", line 55, in
    NameError: name 'vTextArea' is not defined

    ReplyDelete
    Replies
    1. Luis, you will need to define the input when you create the script.

      Add a new 'Script Parameter', giving it the name 'vTextArea' and selecting 'Visualisation' for Type, then - from the dropdown menu - find the text area you want to populate.

      Delete
    2. Thank you!! I had the same question. it works perfectly now.

      Delete
  10. hI
    I am new to spotfire . Can you help me how i can implement this in my dashbord

    ReplyDelete
  11. Hi Sanu,

    You have to create 2 text areas:
    1. you will create the button to execute the script
    2. to show the result of the script "filter schema", Title this area as "vTextArea"
    - On text area for button insert an "Action Control"
    - On the left select "Script"
    - Control Type "button"
    - New Script with the provided code.
    - Add a script parameter and name it vTextArea
    - link the vTextArea parameter to the visualization where you want to show the filter schema "TabName>vTextArea"
    - Close all the way with Ok or save where required.

    Regards,

    Luis R.

    ReplyDelete
  12. HI Luis,
    For the Combination Chart it´s the another parameters?

    send the error when attribute the visualization in parameters

    File "", line 56, in
    AttributeError: 'CombinationChart' object has no attribute 'HtmlContent'

    ReplyDelete
  13. Hey Brother,


    Thank you! Thank you! Thank you! Your blog was a total game changer!


    I am doing a POC on TIBCO MFT PS just to understand its capability and usages. I have never worked on nodes files transfer or file transfer tools. Could anyone help me understanding
    the installtion
    procedure and how to start using it. What needs to be done to configure the PS to send and receive file.





    Follow my new blog if you interested in just tag along me in any social media platforms!


    Shukran,
    Ajeeth Kapoor

    ReplyDelete
  14. Hello There,


    Amaze! I have been looking bing for hours because of this and i also in the end think it is in this article! Maybe I recommend you something helps me all the time?

    In Web Player application, there is an attribute to logout a user on inactivity logout (inactivityTimeout - Spotfire.Dxp.Worker.Web.config).
    Unfortunately it only works in library browser.
    So, it doesn't work when an analysis is open or on an administrator page like "Users & Groups".
    Is it possible to have a global inactivity timeout function to logout a user when he does nothing during a period of time (i.e. 15min)?
    Please note "Absolute session timeout" is not convenience for our users because they need to login every 15min.

    I look forward to see your next updates.


    Merci Beaucoup,
    Indu

    ReplyDelete
  15. Would be nice to have one more comment in there to explain what it is that you are doing. I've picked up a report that has something like this code in there (probably cut and paste) and it is not working. Debugging it is a nightmare because it is not clear what each code block is supposed to be doing.

    ReplyDelete
  16. Hello There,

    10/10 !!! Thank you for making your blogs an embodiment of perfection and simplicity. You make everything so easy to follow.

    I am trying to connect to LinkedIn API via BW Container edition and need Container edition and need to pass Access token to get the response. However i do not see any configuration related to OAuth in REST Refrence or Invoke REST API palltete.
    Follow my new blog if you interested in just tag along me in any social media platforms!

    Obrigado,
    Preethi

    ReplyDelete
  17. Hi
    I have to control some deviation using text area.EG:if i select india in drop down list it has to give population %..Can any one help on this

    ReplyDelete
  18. how to get filtered values in spotfire with out action buttons when we click filter values selected values shoud be display

    ReplyDelete
  19. Nice Article! We are a leading water filter service provider near you . We service all brands and models of water filters. We have skilled and eco-friendly staff to service your RO.

    ReplyDelete