Jump to content
  • How to Remove All and None options from filters in Spotfire® using IronPython Script


    This article contains sample code of how to Remove All and None options from filters in Spotfire® using IronPython Script

    Introduction

    Spotfire® 11.2 has a new capability added for removing the (All) and/or (None) options from the item filters, list box filters, and radio button filters. See What's New in Spotfire®  for more details.

    The feature can be useful, for example, when creating reports where you want the data to always be filtered. By default, (All) and (None) are included in item and radio button filters. In list box filters, (All) is included by default.

    Filter Properties

    This can be achieved by Right-clicking the filter, and checking/unchecking the Include (All) as option and Include (None) as option settings.

    The new capability is also accompanied with an addition to the new Client API's namely AllowAll and ShowNone that allows you to automate this functionality in IronPython scripts or custom extensions.

    Code Sample

    # Copyright © 2019. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    # For Spotfire versions 11.2 and above.
    
    # This sample script is written with respect to Radio Button Filter.
    import Spotfire.Dxp.Application.Filters as filters
    import Spotfire.Dxp.Application.Filters.RadioButtonFilter
    from Spotfire.Dxp.Application.Filters import FilterTypeIdentifiers
    
    page = Application.Document.ActivePageReference
    filterPanel = page.FilterPanel
    
    for table in filterPanel.TableGroups:
    	if table.Name==Document.Data.Tables['SalesAndMarketing'].Name:
    		#print filterPanel.TableGroups.IndexOf(table)
    		myFilter=filterPanel.TableGroups[filterPanel.TableGroups.IndexOf(table)].GetFilter('Region')
    		rbFilter=myFilter.FilterReference.As[filters.RadioButtonFilter]()
    
    # Hide/Show (All)
    
    if rbFilter.AllowAll  == True:
    	rbFilter.AllowAll = False
    else:
    	rbFilter.AllowAll = True
    
    # Hide/Show (None)
    if rbFilter.ShowNone  == True:
    	rbFilter.ShowNone = False
    else:
    	rbFilter.ShowNone = True
     

    References

     

    License:  TIBCO BSD-Style License

    Back to IronPython Scripting in Spotfire Examples

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...