|
Report Application Server .NET SDK Developer Guide
|
|
To navigate the Totaller tree
|
|
This example assumes that you have a report that contains at least one level of grouping.
You can navigate to a node in the Totaller tree by creating a group path that represents its location, or by recursively iterating through the tree using the GetSubTotallerNodes method.
- Create a new GroupPath object.
|
Visual Basic
|
|
|
Dim groupPath As ISCRGroupPath = New GroupPath()
|
|
C#
|
|
|
ISCRGroupPath groupPath = new GroupPath();
|
The GroupPath object represents where a node is positioned in the tree.
- Use thefromString method to specify the path to the node in the Totaller tree.
- To specify the report level, which is the root node of the Totaller tree, use the empty string "".
|
Visual Basic
|
|
|
groupPath.FromString("")
|
|
C#
|
|
|
groupPath.FromString("");
|
- To specify the path to a node by field value, separate each item with the / character.
|
Visual Basic
|
|
|
groupPath.FromString("/Canada/BC")
|
|
C#
|
|
|
groupPath.FromString("/Canada/BC");
|
- To specify a node by field name and field value, use the format field name[field value], and separate each item with the / character.
|
Visual Basic
|
|
|
groupPath.FromString("Country[Canada]/Region[MB]")
|
|
C#
|
|
|
groupPath.FromString("Country[Canada]/Region[MB]");
|
- To specify a node by the numeric value of its position in the Totaller tree, separate each item with the - character.
|
Visual Basic
|
|
|
groupPath.FromString("1-0")
|
|
C#
|
|
|
groupPath.FromString("1-0");
|
- Create a new Totaller node, and set it by calling the RowsetController.GetTotallerNode method using the group path as the argument.
|
Visual Basic
|
|
|
Dim totallerNode As ISCRTotallerNode = New TotallerNodeClass() totallerNode = rcd.RowsetController.GetTotallerNode(groupPath)
|
|
C#
|
|
|
ISCRTotallerNode totallerNode = new TotallerNodeClass(); totallerNode = rcd.RowsetController.GetTotallerNode(groupPath);
|
- Retrieve the children of the node using the GetSubTotallerNodes method.
|
Visual Basic
|
|
|
Dim children As ISCRTotallerNodes = rcd.RowsetController.GetSubTotallerNodes(groupPath)
|
|
C#
|
|
|
ISCRTotallerNodes children = rcd.RowsetController.GetSubTotallerNodes(groupPath);
|
- Iterate through the children of the Totaller node.
|
Visual Basic
|
|
|
Dim nodeNames As [String] = "" For i As Integer = 0 To currentNodes.Count - 1 nodeNames += currentNodes(i).Name & " " Next
|
|
C#
|
|
|
String nodeNames = ""; for (int i = 0; i < currentNodes.Count; i++) { nodeNames += currentNodes[i].Name + " "; }
|
- Return the string that contains node information.
|
Visual Basic
|
|
|
Return nodeNames
|
This sample recursively traverses the Totaller tree from the root level and returns the name of each node. Modify the traverseChildren method to manipulate each node of the totaller.
|
Visual Basic
|
|
|
Private Function TraverseTotaller(ByVal rcd As ISCDReportClientDocument) As String Dim groupPath As ISCRGroupPath = New GroupPath() groupPath.FromString("") Dim totallerNode As ISCRTotallerNode = New TotallerNodeClass() totallerNode = rcd.RowsetController.GetTotallerNode(groupPath) Dim children As ISCRTotallerNodes = rcd.RowsetController.GetSubTotallerNodes(groupPath) Dim nodeNames As String = "" TraverseChildren(rcd, children, nodeNames) Return nodeNames End Function Private Sub TraverseChildren(ByVal rcd As ISCDReportClientDocument, ByVal currentNodes As ISCRTotallerNodes, ByRef nodeNames As String) For i As Integer = 0 To currentNodes.Count - 1 nodeNames += currentNodes(i).Name & " " Dim currentPath As ISCRGroupPath = currentNodes(i).GroupPath Dim childNodes As ISCRTotallerNodes = rcd.RowsetController.GetSubTotallerNodes(currentPath) TraverseChildren(rcd, childNodes, nodeNames) Next End Sub
|
|
C#
|
|
|
private String TraverseTotaller(ISCDReportClientDocument rcd) { ISCRGroupPath groupPath = new GroupPath(); groupPath.FromString(""); ISCRTotallerNode totallerNode = new TotallerNodeClass(); totallerNode = rcd.RowsetController.GetTotallerNode(groupPath); ISCRTotallerNodes children = rcd.RowsetController.GetSubTotallerNodes(groupPath); String nodeNames = ""; TraverseChildren(rcd, children, ref nodeNames); return nodeNames; } private void TraverseChildren(ISCDReportClientDocument rcd, ISCRTotallerNodes currentNodes, ref String nodeNames) { for (int i = 0; i < currentNodes.Count; i++) { nodeNames += currentNodes[i].Name + " "; ISCRGroupPath currentPath = currentNodes[i].GroupPath; ISCRTotallerNodes childNodes = rcd.RowsetController.GetSubTotallerNodes(currentPath); TraverseChildren(rcd, childNodes, ref nodeNames); } }
|
This list includes the namespaces used by the sample code:
- CrystalDecisions.Enterprise
- CrystalDecisions.ReportAppServer.ClientDoc
- CrystalDecisions.ReportAppServer.Controllers
- CrystalDecisions.ReportAppServer.DataDefModel
© 2021 SAP AG. All rights reserved.
http://www.sap.com/sapbusinessobjects/
Support services
http://service.sap.com/bosap-support/
Created with the Personal Edition of HelpNDoc: Produce Kindle eBooks easily