1

I have a column that is set as a checkbox filter which has two values ("Refund" and "EMPTY"). I'd like to set that filter to have only the "Refund" box checked, but I can't find out how to set it.

How is this done easily in IronPython?

Keng
  • 52,011
  • 32
  • 81
  • 111

2 Answers2

3

Set Filters Programatically (from a text input field)

  • You have an input field in a text area (colname document property)
  • You can pass multiple values (space separated) to the filter from the text area input field.
  • You want to take the value from this text field and pass the value to a filter named 'Site Name'
  • The filter in the filter palnel is a ListBoxFilter

enter image description here

import Spotfire.Dxp.Application.Filters as filters
import Spotfire.Dxp.Application.Filters.ListBoxFilter
from Spotfire.Dxp.Application.Filters import FilterTypeIdentifiers
from Spotfire.Dxp.Data import DataPropertyClass
from System import String
myPanel = Document.ActivePageReference.FilterPanel
myFilter= myPanel.TableGroups[0].GetFilter("Site Name")
lbFilter = myFilter.FilterReference.As[filters.ListBoxFilter]()
lbFilter.IncludeAllValues=False
strVals = Document.Properties["colname"]
if strVals!=String.Empty:
  lbFilter.SetSelection(strVals.split())
else:
  lbFilter.Reset()

Reference: http://spotfired.blogspot.com/2014/03/change-filters-programatically-from.html

Jacek Sierajewski
  • 613
  • 1
  • 11
  • 33
  • 2
    @Keng, the important part of this is the line `lbFilter.IncludeAllValues=False`, which maybe should be called `lblFilter.IsEmptyChecked`. setting to `True` would tick the **(Empty)** box. – niko Nov 09 '15 at 01:34
1

Here's how I'm setting the checkbox filters. TOH to @Niko and @Jacek Sierajewski for the "(Empty)" hint for cb filter settings!

from Spotfire.Dxp.Application import Filters as filters
strTtype= Document.Properties['Ttype']
FilterSelection = Document.Data.Filterings["Main Scheme"]
cbfRefund = Document.FilteringSchemes[FilterSelection][Document.Data.Tables["Transaction Data"]]["Refund Transaction"].As[filters.CheckBoxFilter]()
if strTtype=="Refund":
    for CheckBoxValue in cbfRefund.Values:
        cbfRefund.Uncheck(CheckBoxValue)
        if CheckBoxValue == "Refund":
            cbfRefund.Check(CheckBoxValue)
            cbfRefund.IncludeEmpty=False#This clears the "(Empty)" checkbox
Keng
  • 52,011
  • 32
  • 81
  • 111