Setting the hierarchical filter in a custom extension is not same as setting it through a python script. This example provides sample code to explain the difference in IronPython and C#
Introduction
Setting the hierarchical filter in a custom extension is not same as setting it through a python script. This example provides sample code to explain the difference in IronPython and C#
Code sample
# Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license. # Get the Filter myDateFilter = myPanel.FilteringSchemeReference.DefaultFilterCollection["MyDateHierarchy"]; hierFilter_date = myDateFilter.As[CheckBoxHierarchyFilter](); # Uncheck all nodes hierFilter_date.UncheckAllNodes() # Check all nodes hierFilter_date.CheckAllNodes() # Select specific node # A date hierarchical filter can represented as year-Quarter-Month, # but when setting these filters their integer equivalents need to be used # e.g.: 1/2/2014 - The hierarchical filter would be represented as: # 2014 # Q1 (1) # Feb (2) hierFilter_date.Check(DistinctDataValue(2014),DistinctDataValue(1),DistinctDataValue(2)) # Check/Uncheck specific Node For a hierarchical filter containing a combination of strings and integers - hierFilter_country.Check(DistinctDataValue("India"),DistinctDataValue("Pune"),DistinctDataValue(2000)) hierFilter_country.UnCheck(DistinctDataValue("India"),DistinctDataValue("Pune"),DistinctDataValue(2000))
Equivalent C# sample code to check/uncheck the hierarchical filter:
// Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license. //Select last top-level node. CheckBoxHierarchyFilter hf = filterPanel.TableGroups[0].GetFilter("My Custom Hierarchy").FilterReference.As(); DataHierarchy hierarchy = hf.Hierarchy; DataNodeCollection hierarchyRootNodes; hierarchy.Levels.RootLevel.TryGetNodes(int.MaxValue, out hierarchyRootNodes); DataNode lastRootNode = hierarchyRootNodes[hierarchyRootNodes.Count - 1]; DistinctDataValue value = new DistinctDataValue(lastRootNode.Value.ValidValue); hf.Check(value); // Uncheck second top-level node's last child node. DataNode secondRootNode = hierarchyRootNodes[1]; DistinctDataValue secondTopLevelValue = new DistinctDataValue(secondRootNode.Value.ValidValue); DataNode secondTopLevelNodesLastChild = secondRootNode.Children[secondRootNode.Children.Count - 1]; DistinctDataValue secondTopLevelNodesLastChildValue = new DistinctDataValue(secondTopLevelNodesLastChild.Value.ValidValue); hf.UnCheck(secondTopLevelValue, secondTopLevelNodesLastChildValue);
References
License: TIBCO BSD-Style License
Recommended Comments
There are no comments to display.