Jump to content

Creating Hierarchy Column and moving associated Filter to TableGroup.Subgroup


Jana Kneissl

Recommended Posts

Hello TIBCO Community,

 

I am working on an IronPython script to create a new hierarchy column and then move the filter associated with the hierarchy to a TableGroup.Subgroup.

 

In my script I am doing the following:

###############################################################################

 

filterPanel = Document.ActivePageReference.FilterPanel

 

# get the correct tableGroup

for tableGroup in filterPanel.TableGroups:

if tableGroup.Name == "Result Table Group":

resultTableGroup = tableGroup

 

# get the correct dataTable

for table in Document.Data.Tables:

if table.Name == "Result Table":

resultDataTable = table

 

# create new subgroup

hierarchyfilterGroup = resultTableGroup.AddNewSubGroup("Result hierarchy subgroup")

 

filterPanel.InteractiveSearchPattern = ""

for filterHandle in filterPanel.FiltersMatchingSearchPattern:

tableGroupFilterHandle = resultTableGroup.GetFilter(filterHandle.FilterReference.Name)

 

if tableGroupFilterHandle != None:

tableGroupFilterHandle.Visible = False # hide filter in table group

 

# create a new hiearchy column

hierarchyColName = tableGroupFitlerHandle.FilterReference.Name + " - process hierarchy"

hierarchyExpressions = List[str]()

hierarchyExpressions.Add("[" + tableGroupFitlerHandle.FilterReference.Name + "]")

hierarchyExpressions.Add("[Process]")

hierarchy = HierarchyDefinition(HierarchyNestingMode.Nested, hierarchyExpressions)

resultDataTable.Columns.AddHierarchyColumn(hierarchyColName, hierarchy)

 

# try to get the hierarchy associated filter

hieararchyFilterHandle = tableGroup.GetFilter(hierarchyColName)

if hiearchyFilterHandle != None:

hierarchyfilterGroup.Add(hierarchyFilter.FilterReference)

 

##################################################################################

 

However,tableGroup.GetFilter(hierarchyColName) always returns 'None' for the hiearchy columns. As a result of running the script, I get the hierarchy filters correctly and I also see the subgroup correctly, but the hierarchy filters are not sorted into the subgroup.

Here are some other things I have tried:

1. Searching the whole FilterPanel for the hiearachy filter

FilterPanel.InteractiveSearchPattern = hierarchyColName

for filterHandle in filterPanel.FiltersMatchingSearchPattern:

...--> does not find any MatchingFilters

 

2. Refreshing the dataTable before trying to find the filter

resultDataTable.Refresh()

...

--> has no effect on the resultCould you please help me moving the hierarchy filter to the newly created subgroup

 

Thank you in advance!

Link to comment
Share on other sites

  • 2 weeks later...

Answering my own question in case others need it later:

 

# get the correct tableGroup

for tableGroup in filterPanel.TableGroups:

if tableGroup.Name == "Result Table Group":

resultTableGroup = tableGroup

 

# get the correct dataTable

for table in Document.Data.Tables:

if table.Name == "Result Table":

resultDataTable = table

 

# create new subgroup

hierarchyfilterGroup = resultTableGroup.AddNewSubGroup("Result hierarchy subgroup")

 

filterPanel.InteractiveSearchPattern = ""

for filterHandle in filterPanel.FiltersMatchingSearchPattern:

tableGroupFilterHandle = resultTableGroup.GetFilter(filterHandle.FilterReference.Name)

 

if tableGroupFilterHandle != None:

tableGroupFilterHandle.Visible = False # hide filter in table group

 

# create a new hiearchy column

hierarchyColName = tableGroupFitlerHandle.FilterReference.Name + " - process hierarchy"

hierarchyExpressions = List[str]()

hierarchyExpressions.Add("[" + tableGroupFitlerHandle.FilterReference.Name + "]")

hierarchyExpressions.Add("[Process]")

hierarchy = HierarchyDefinition(HierarchyNestingMode.Nested, hierarchyExpressions)

resultDataTable.Columns.AddHierarchyColumn(hierarchyColName, hierarchy)

 

colExists, hierarchyCol = resultDataTable.Columns.TryGetValue(hierarchyColName)

resultTableGroup.FilterCollectionReference.AddNewFilter(hierarchyCol)

 

# move the filter to the subgroup

hierarchyFilterHandle = resultTableGroup.GetFilter(hierarchyColName)

hierarchyFilterHandle.Visible = True

dynamicSubGroup.Add(hierarchyFilterHandle.FilterReference)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...