Reply
 
LinkBack Thread Tools Display Modes
Old 04-22-2011, 11:47 PM   #1 (permalink)
Member
 
Join Date: Apr 2011
Posts: 32
engcosta is on a distinguished road
Default why i have repeatation in names in subreport

i made a report that calculate the zone summary and the report is grouped (ByZone) and it was the result



after that i made that zone summary report as a subReport in another report that is grouped
(ByLocation ByZone) the problem is here it gives me that result

and i don't want that repeatation in names i need all zone have the same name to be grouped together
engcosta is offline   Reply With Quote
Old 04-23-2011, 08:43 AM   #2 (permalink)
Senior Member
 
Join Date: May 2009
Location: Chennai, India
Posts: 157
nkarthick is on a distinguished road
Default Try this

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.
__________________
Narayana Karthik
nkarthick is offline   Reply With Quote
Old 04-23-2011, 10:15 AM   #3 (permalink)
Member
 
Join Date: Apr 2011
Posts: 32
engcosta is on a distinguished road
Default

the report when i privew it works fine but when i make publish it gives me that error message
engcosta is offline   Reply With Quote
Old 04-23-2011, 10:17 AM   #4 (permalink)
Member
 
Join Date: Apr 2011
Posts: 32
engcosta is on a distinguished road
Default

And that is the complete code now

Imports System.Xml
Imports DTools.SystemIntegrator.Reporting
Imports System.Collections.Generic

Private ds As DataDynamics.ActiveReports.Datasources.XMLDatasour ce = Nothing
Private doc As XmlDocument
Private xmlRoot As XmlElement
Private xmlns As XmlNamespaceManager = Nothing

Sub ActiveReport_ReportStart

ReportUtilities.ApplyDataSourceFilter(rpt,1)
SortItemsByZone()

End Sub

Sub SortItemsByZone()

ds = rpt.DataSource
doc = ds.Document
xmlRoot = doc.DocumentElement


xmlns = ReportingNamespaceUtility.ReturnXMLNamespaceManage r(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).Inner Text

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.XMLDataSour ce(ds.FileURL, ds.RecordsetPattern)
rpt.DataSource = xmlDS

xmlDS.LoadXML(xmlDS.Document.OuterXml)

'reset the Xml Document
ReportUtilities.SetXMLDocument(xmlDS.Document)

End Sub



Sub GrpDynamicHeader1_BeforePrint

try
Dim total As Decimal = CType(ReportUtilities.ReturnTextBoxValue(rpt,"GrpD ynamicHeader1","txtGrp3Price"),Decimal)
ReportUtilities.SetControlVisibility(rpt, "txtGrp3Price", total<>0)
ReportUtilities.SetControlVisibility(rpt, "txtDynamicHeader1", total<>0)
catch
End try

End Sub
engcosta is offline   Reply With Quote
Old 04-23-2011, 10:27 AM   #5 (permalink)
Member
 
Join Date: Apr 2011
Posts: 32
engcosta is on a distinguished road
Default

its okai now i fixed that error by putting try and catch to handel that exception inside the SortItemsByZone() method

thank you very much nkarthick for help
engcosta is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:36 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.0
D-Tools, Inc.