Jump to content
  • How to loop through bookmarks and display Filter Settings to Text Area in Spotfire® Using IronPython Scripting


    This article provides a sample IronPython script that helps to loop through the bookmarks and display filter settings.

    Introduction

    Here is the sample IronPython script that helps to loop through the bookmarks and display filter settings.

    Code Sample

    # Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
     
    import clr
    clr.AddReference("System.Windows.Forms")
    from System.Windows.Forms import MessageBox
    from System.Text import *
    from Spotfire.Dxp.Application.AnalyticItems import BookmarkManager
    import Spotfire.Dxp.Application.Filters as filters
    from Spotfire.Dxp.Application.Visuals import HtmlTextArea
    
    textArea= None
    builder=StringBuilder()
    htmlContent=None
    
    #Get Bookmark Manager
    bookmarkManager = Application.GetService(BookmarkManager)
    
    #Loop through bookmarks and apply each bookmark
    for bookmark in bookmarkManager.GetBookmarks():
    	bookmarkManager.Apply(bookmark,0)
    	MessageBox.Show("Applied bookmark: "+bookmark.Name)
    	myPanel= Document.ActivePageReference.FilterPanel
    	for tables in Document.Data.Tables:
    		filterCollection= myPanel.FilteringSchemeReference.Item[tables]
    		builder.AppendLine("Filters for applied for Bookmark"+bookmark.Name+"\n")
    		builder.AppendLine("Filters in "+tables.Name)
    		for filters in filterCollection:
    			builder.AppendLine(str(filters.Context))
    			builder.AppendLine("\n")
    			
    #Add the Filter settings to Text Area with title Filters in Different Bookmarks			
    for vis in Document.ActivePageReference.Visuals:
    	if vis.Title=="Filters in Different BookMarks":
    		textArea=vis
    		htmlContent=vis.As[HtmlTextArea]().HtmlContent
    textArea.As[HtmlTextArea]().HtmlContent=builder.ToString()
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...