I need some help with creating a select all script for a multi-select listbox control.
Hi all, I need some help with creating a select all script for a multi-select listbox control. I can do it with a checkbox property control, but there are too many items in this case, so I need to use a listbox control. Basically, I have a multiselect listbox property control named "SelectSoldToParty" that passes values to the filter for the "Sold To Party_" column in my table (named "Spotfire Table Links Master"). It's not a problem to actually select all the values in the filter; the problem is how to show in the property control listbox that all the items are selected (I want to hide the filter panel from the users). I've copied below the script that executes when someone selects an item(s) in the property control (I'm on version 6.5 btw), but I'm having trouble modifying it so that in addition to selecting all the items in the filter, it shows in the property control that all the items are selected, by highlighting them all. Can anyone help? Thanks!
from Spotfire.Dxp.Application import Filters
from Spotfire.Dxp.Application.Filters import FilterPanel
from Spotfire.Dxp.Application.Filters import FilterTypeIdentifiers
from Spotfire.Dxp.Application.Filters import ListBoxFilter
from Spotfire.Dxp.Data import DataPropertyClass
from System import Array
from System import String
for table in Document.Data.Tables:
myPanel = Application.Document.ActivePageReference.FilterPanel
myFilter=Document.FilteringSchemes[Document.ActiveFilteringSelectionReference].Item[table].Item[table.Columns.Item["Sold To Party_"]].As[ListBoxFilter]()
myFilter.SetSelection() # Deselect any current choices
myFilter.IncludeAllValues = False # Don't include the 'All' choice
#set "selection" equal to the value(s) selected in the property control
selection = Document.Data.Properties.GetProperty(DataPropertyClass.Document, "SelectSoldToParty").Value
# Create an array of from the user's selection(s) for user later
userFilterValues = Array[str]([str(x) for x in selection])
# ListBoxFilter.SetSelection() doesn't like it if you pass it a value that doesn't exist, so we have to go through# all of the existing data set values and verify the user's input exists. If it does, then it goes into this array.
myFilterValues = 
# Grab the data set values for the column "Sold To Party_"
cols = table.Columns
col = cols.Item['Sold To Party_']
rowEnum = col.RowValues.GetEnumerator()
# Loop through all the data set's "Sold To Party_" column values and compare them with the user's input. Store any matching values.
for row in rowEnum:
if row.Value in userFilterValues:
# Finally, tell the ListBoxFilter to select those values