Matthew Henrich Posted February 7, 2022 Share Posted February 7, 2022 I am attempting to write an IronPython script that will look at all nodes of a CheckboxHierarchyFilter and return only the values that are currently checked. This question was similarly asked here:https://community.spotfire.com/questions/iterate-through-items-checkboxhierarchy-filterand that is how I got the base level (*.Heirarchy.Level[0]), but I cannot get the 2nd - 4th levels to be read correctly. When I try to follow the instructions on that page/question, I keep getting a "Looking for Array(DistinctDataValue), but got bool." error. Can someone enlighten me on how to do thisIsChecked(List) doesn't seem to be the right answer. Link to comment Share on other sites More sharing options...
Gaia Paolini Posted February 10, 2022 Share Posted February 10, 2022 could you show a sample of your hierarchy Link to comment Share on other sites More sharing options...
Matthew Henrich Posted February 10, 2022 Author Share Posted February 10, 2022 The hierarchy was created in the Spotfire Tool - what example are you looking for Link to comment Share on other sites More sharing options...
Gaia Paolini Posted February 10, 2022 Share Posted February 10, 2022 I meant what the data looks like, I was guessing the issue might be related to what your actual hierarchy is Link to comment Share on other sites More sharing options...
Matthew Henrich Posted February 10, 2022 Author Share Posted February 10, 2022 There are three heirarchies that this code needs to work for Business -> Organization -> Sub-Business Business -> Region -> Country Business -> Custom Region -> Country Link to comment Share on other sites More sharing options...
Matthew Henrich Posted February 10, 2022 Author Share Posted February 10, 2022 Gaia - can you give an example of how IsChecked(List<DistinctDataValue>) is supposed to work Link to comment Share on other sites More sharing options...
Matthew Henrich Posted February 10, 2022 Author Share Posted February 10, 2022 * This is not meant to be an answer. Link to comment Share on other sites More sharing options...
Andrew Berridge Posted February 11, 2022 Share Posted February 11, 2022 Hi Matt, I'm taking a look at this now. It is possible to do what you want, but that referenced script isn't the right way to do it. I'll update with another answer later on. Andrew Berridge (TIBCO Data Science) Link to comment Share on other sites More sharing options...
Andrew Berridge Posted February 11, 2022 Share Posted February 11, 2022 Also posted here: https://community.spotfire.com/wiki/hierarchical-checkbox-filters-which-values-are-checked Link to comment Share on other sites More sharing options...
Matthew Henrich Posted August 22, 2022 Author Share Posted August 22, 2022 Any update on this? Link to comment Share on other sites More sharing options...
Matthew Henrich Posted August 24, 2022 Author Share Posted August 24, 2022 6 months and no update - nice work Link to comment Share on other sites More sharing options...
Andrew Berridge Posted August 25, 2022 Share Posted August 25, 2022 Hi Matthew - I did write and post an article on this topic at the time, but it looks like my comment pointing you to that script was missed somehow. Let me share the link to the script with you:https://community.spotfire.com/s/article/Hierarchical-Checkbox-filters-which-values-are-checkedDo let us know if it solves your issue! We appreciate your feedback,Andrew Link to comment Share on other sites More sharing options...
Matthew Henrich Posted August 25, 2022 Author Share Posted August 25, 2022 It doesn't solve my issue, and your comment after the initial posting of that link says the same. How do I utilize the Check(List<DistinctDataValue>) function to actually work with a list? Link to comment Share on other sites More sharing options...
Andrew Berridge Posted August 25, 2022 Share Posted August 25, 2022 Hi Matthew,OK - here is how you can tell if an item is checked:import Systemfrom System import Arrayfrom Spotfire.Dxp.Data import DistinctDataValueimport Spotfire.Dxp.Application.Filters as filtersfrom System.Collections.Generic import List myPanel = Document.ActivePageReference.FilterPanelmyFilter = myPanel.TableGroups[0].GetFilter("New hierarchy")chFilter = myFilter.FilterReference.As[filters.CheckBoxHierarchyFilter]() l = List[DistinctDataValue]() l.Add(DistinctDataValue("California"))l.Add(DistinctDataValue("conventional"))print(chFilter.IsChecked(l))The values "California" and "conventional" are the values in levels 1 and 2 in the hierarchy I'm using.The original example I posted is more generic - in that it recursively navigates the entire hierarchy.Hopefully you can translate that to your needs. Let us know how you get on!Andrew Link to comment Share on other sites More sharing options...
Andrew Berridge Posted August 26, 2022 Share Posted August 26, 2022 Last reply updated 26-Aug - using IsChecked method rather than Check method. 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