Brittany Wiechelman Posted October 24, 2019 Share Posted October 24, 2019 I have a multi-line textbox that users enter their list of values into, with each value separate on a new line. If one value is not found in the data set, then it won't even filter for any of the values that are found. Currently the code throws a generic error "One or more values is not found in the dataset". I want to tell the user what value was not found, and continue to filter for the values that were found.I think I have to set a Document Property for ValuesNotFound and display it, but unsure how to get the ValuesNotFound output. Code below: 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 Document.Properties["listFilterMessage"] = "Status: filtering..." myPanel = Document.ActivePageReference.FilterPanel myFilter= myPanel.TableGroups[2].GetFilter("part_number") lbFilter = myFilter.FilterReference.As[filters.ListBoxFilter]() lbFilter.IncludeAllValues=False strVals = Document.Properties["ListParts"] if strVals!=String.Empty: try: lbList=strVals.split("n") lbList = filter(len, lbList) lbFilter.SetSelection(lbList) Document.Properties["listFilterMessage"] = "Status: filtered" print("Status: filtered") except: Document.Properties["listFilterMessage"] = "Error: at least one part number may not be in dataset" print("filter failed: at least one part number may not be in dataset") else: lbFilter.Reset() Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted October 24, 2019 Share Posted October 24, 2019 You can use the below script as a reference to search if a given value exists or not and then set the filtering based on the valid values import System.String as String from Spotfire.Dxp.Application import Filters as filters myPanel = Document.ActivePageReference.FilterPanel myFilter = myPanel.TableGroups[0].GetFilter("Region") listboxFilter = myFilter.FilterReference.As[filters.ListBoxFilter]() #get the value from input field values=Document.Properties["search"] try: userInput=values.split("n") print userInput except: print "failed" #create a list for setting listbox filter setSelection=set() #get the column reference to search for columnRef=listboxFilter.DataColumnReference columnValuesCollection=columnRef.RowValues.GetEnumerator() #read the column values and check if they are in userinput for columnValue in columnValuesCollection: if columnValue.ValidValue in userInput: # if valid exists then add it to the filtering list setSelection.add(columnValue.ValidValue) #set ListBoxFilter with the values listboxFilter.IncludeAllValues=False listboxFilter.SetSelection(setSelection) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now