Hi,
The Problem is Groupings in your Main report,
If you run your Main report By Location and By Zone. It will sort Items by Location first and then by Zone, thats why zone info repeated more than once.
Not Understand?
Will explain it with example -
Consider a Project with 3 Products
Product A , Product B, Product C and Product D
Product A in Location 1,and in Zone A
Product B in Location 1, and in Zone B
Product C in Location 2 and in Zone A
Product D in Location 1 and in Zone B
When you run report by Location and Zone, Product Items are sorted in below order Location first and then Zone
Product A - Location 1 - Zone A
Product B - Location 1 - Zone B
Product D - Location 1 - Zone B
Product C - Location 2 - Zone A
then your zone summary will display in below order
Zone A
Zone B
Zone A
For active report groupings to work - the items need to be sorted in group datafield order.
For you Main report - Grouping (by Location By Zone) has override your sub report sortings.
To Overcome this Problem -
In your Zone Summery report you have to persist the Items sorting by zone.
This will be acheived via script only.
In your Zone Summary report include the below script -
|
Code:
|
Imports System.Xml
Imports DTools.SystemIntegrator.Reporting
Imports System.Collections.Generic
Private ds As DataDynamics.ActiveReports.Datasources.XMLDatasource = Nothing
Private doc As XmlDocument
Private xmlRoot As XmlElement
Private xmlns As XmlNamespaceManager = Nothing
Sub ActiveReport_ReportStart
SortItemsByZone()
End Sub
Sub SortItemsByZone()
ds = rpt.DataSource
doc = ds.Document
xmlRoot = doc.DocumentElement
xmlns = ReportingNamespaceUtility.ReturnXMLNamespaceManager(doc.NameTable)
Dim xmlItemsRootNode As XmlNode = xmlRoot.SelectSingleNode("//dtr:Items",xmlns)
Dim xmlNodeList As XmlNodeList = xmlRoot.SelectNodes("//dtr:Items/dtr:Item",xmlns)
Dim zones As New List(Of String)
Dim zoneDict As New Dictionary(Of String, List(Of XmlNode))
Dim keys As New List(Of String)
For Each node As XmlNode In xmlNodeList
Dim zone As String = node.SelectSingleNode("dtr:ZoneOrder",xmlns).InnerText
If(zoneDict.ContainsKey(zone)) Then
Dim xmlNodes As List(Of XmlNode) = zoneDict(zone)
xmlNodes.Add(node)
Else
keys.Add(zone)
Dim xmlNodes As New List(Of XmlNode)
xmlNodes.Add(node)
zoneDict.Add(zone, xmlNodes)
End If
Next
keys.Sort()
xmlItemsRootNode.RemoveAll()
For Each key As String in keys
Dim xmlNodes As List(Of XmlNode) = zoneDict(key)
For Each node2 As XmlNode in xmlNodes
xmlItemsRootNode.AppendChild(node2)
Next
Next
ds.Document.Save(ds.FileURL)
Dim xmlDS As New DataDynamics.ActiveReports.DataSources.XMLDataSource(ds.FileURL, ds.RecordsetPattern)
rpt.DataSource = xmlDS
xmlDS.LoadXML(xmlDS.Document.OuterXml)
'reset the Xml Document
ReportUtilities.SetXMLDocument(xmlDS.Document)
End Sub |
Hope it helps.