Reply
 
LinkBack Thread Tools Display Modes
Old 08-05-2009, 08:18 PM   #1 (permalink)
Senior Member
 
Join Date: Jul 2008
Location: Olympia, WA
Posts: 342
grichards is a jewel in the roughgrichards is a jewel in the roughgrichards is a jewel in the roughgrichards is a jewel in the rough
Send a message via Skype™ to grichards
Default sub-report force groupings

i can't seem to get a sub-report to group properly. I've set required grouping to "Phase" in the report setup. I've also set the data field of the group to dtr:Phase. when i run the report preview it works fine. when i include it as a sub report multiple occurences of each phase show up.

what am i doing wrong? can i force grouping through scripting?

as an additional note: it seems like the sub-report is adopting the grouping of the parent report, even though i though i disabled the dynamic grouping in the sub-report.

Last edited by grichards; 08-05-2009 at 09:49 PM. Reason: added note about dynamic grouping
grichards is offline   Reply With Quote
Old 08-06-2009, 02:47 PM   #2 (permalink)
Certified Partner
 
Ryan Brown's Avatar
 
Join Date: Mar 2006
Location: San Diego, CA
Posts: 182
Ryan Brown has much to be proud ofRyan Brown has much to be proud ofRyan Brown has much to be proud ofRyan Brown has much to be proud ofRyan Brown has much to be proud ofRyan Brown has much to be proud ofRyan Brown has much to be proud ofRyan Brown has much to be proud ofRyan Brown has much to be proud of
Default

Hey there - you're right the subreports adopt any grouping settings being used in the parent report - in addition to filtering options from the parent report. The solution lies in script for both of these - to alter filtering or grouping in a subreport to be different from its parent.

There is actually a helper file created awhile back by Rick C at this URL. It's called 'Resort Items in Script' under the subreports header. It has good instructions inside his sample code.

Custom Report Advanced

Hope this helps!
__________________
Ryan Brown
Media Environment Design
Founding D-Tools Certified Partner
(760) 434-9040
ryanbrown@medesign.tv
Linked In
D-Tools Custom Reports
Free D-Tools QuickTips Videos
Ryan Brown is offline   Reply With Quote
Old 08-06-2009, 05:58 PM   #3 (permalink)
Senior Member
 
Join Date: Jul 2008
Location: Olympia, WA
Posts: 342
grichards is a jewel in the roughgrichards is a jewel in the roughgrichards is a jewel in the roughgrichards is a jewel in the rough
Send a message via Skype™ to grichards
Default

Ryan,

thanks for the heads up, i did stumble upon the Resort script in my search yesterday and it works to some extent. The problem is that when i run the report with this script on large projects ( >2000 items) the script will often throw the ever-so-popular target of invocation error and not produce the report. my assumption is that it's a out-of-memory error.
report error.JPG

My thinking is that manipulating the sorting collection in reporting is kind of a round about way to control grouping. Is there not a grouping collection that can be controlled? so far i've seen examples from RickC on adding filters in script and controlling sorting in script. how about grouping?

(chanting) RickC, RickC, RickC!!!

on a related grouping note, i do have a sub-report that i actually WANT to adopt the grouping from the parent and it doesn't. i don't know why this happens either. AR seems clunky at best.
grichards is offline   Reply With Quote
Old 08-06-2009, 08:50 PM   #4 (permalink)
Senior Member
 
Join Date: Jul 2008
Location: Olympia, WA
Posts: 342
grichards is a jewel in the roughgrichards is a jewel in the roughgrichards is a jewel in the roughgrichards is a jewel in the rough
Send a message via Skype™ to grichards
Default

Originally Posted by Ryan Brown View Post
...subreports adopt any grouping settings being used in the parent report - in addition to filtering options from the parent report....

I'm finding that sub-Reports don't actually adopt the filtering options...sometimes
grichards is offline   Reply With Quote
Old 08-07-2009, 06:23 AM   #5 (permalink)
Senior Member
 
Join Date: May 2009
Location: Chennai, India
Posts: 157
nkarthick is on a distinguished road
Default Try this sub report

Grouping in Main report will not be applied to Sub Report. But you can group the Sub Report Items with some design and script work.

In your case you have set Grouping by Phase (dtr: Phase) in the Sub report but it still not shown properly. This is since the items are not ordered correctly. If the Sub report items are ordered correctly then the Grouping in Sub report will be rendered correctly.

Try the below steps for Grouping the Sub Report Items by Phase (Proposal Report)


Proposal Sub Report Changes -
- Create Custom sub report based on existing Proposal Level2 Items report and name it as “Proposal – Sub report”.
- Include a new Group and set the Data Field for the Group dtr:Phase (like you did).
- Add a Textbox control into the new Group header and set the data field property to dtr:Phase and place it in the appropriate location in the Group.
- Replace the code in the script with the below code.
Code:
Imports System.Xml
Imports DTools.SystemIntegrator.Reporting
Imports System.Collections.Generic
Imports  ActiveReports3.DataDynamics.ActiveReports


Private showModel As Boolean
Private showPrice As Boolean
Private showLaborItems As Boolean

Sub ActiveReport_ReportStart


	' Apply Items Filter
	ReportUtilities.ApplyProposalItemLevel2DataSourceFilter(rpt)
	
	'****************************************New  Script Code Starts Here *****************************************************
	
	Dim ds As DataDynamics.ActiveReports.Datasources.XMLDatasource = ctype(rpt.Datasource, DataDynamics.ActiveReports.Datasources.XMLDatasource)
	
	If ds.EOF Then return 
	
	If ds.Count > 0 Then
	
		Dim doc As XmlDocument = ds.Document
	
		'Get the root element
	 	Dim xmlRoot As XmlElement = doc.DocumentElement

		'Get the name space for this xml document
   	 	xmns  = ReportingNamespaceUtility.ReturnXMLNamespaceManager(doc.NameTable)
       
   		Dim mainList As XmlNodeList = xmlRoot.SelectNodes("//dtr:Level2Items",xmns)

      'Get the Phases of the items
		Dim ns As XmlNodeList  = xmlRoot.SelectNodes("//dtr:Level2Items/dtr:ProposalItemLevel2/dtr:PhaseOrder",xmns)
	
		Dim revisedNodeList As New List(Of XmlNode)
	
	  'Get the uniquelist of Phase
		Dim uniqueList As List(Of String) = ReturnUniqueList(ns)
		
		'Sort the unique list values.
		Dim phaseOrdervalues(uniqueList.Count - 1) As String
		
		uniqueList.CopyTo(phaseOrdervalues,0)		
		Array.Sort(phaseOrdervalues)
			
		For Each phase As String in phaseOrdervalues
	
			'get the Items for this phase order.
	    	Dim itemList  As XmlNodeList =  xmlRoot.SelectNodes(String.Format("//dtr:Level2Items/dtr:ProposalItemLevel2[dtr:PhaseOrder  =  {0}]", phase),xmns)
		
			For Each node3 As XmlNode in itemList
				'Add the Revised Items
				revisedNodeList.Add(node3)
		
			Next
	
   		 Next
	
	  'remove all items from the main list
     	mainList(0).RemoveAll()

   		For Each node2 As XmlNode In revisedNodeList
           	're-add the revised (re-ordered) node list
         		mainList(0).AppendChild(node2)
    	Next
        
        'reload the datasource 
  		ds.LoadXML(ds.Document.OuterXml)
	
End If

'*************************************New Script Code Ends here *****************************************************************

	' set the default value
	 showModel = false
	 
	 ' get the parameter value
	Dim showModelParam As object = ReportUtilities.ReturnParameterValue("ShowModel")

	' if the parameter value is not null, then parse it
	If Not showModelParam Is Nothing Then
		
		If Not Boolean.TryParse(showModelParam.ToString, showModel) Then
			showModel = false
		End If

	End If
	
	
	' get the parameter value
	Dim showPriceParam As object = ReportUtilities.ReturnParameterValue("ShowPrice")

	' if the parameter value is not null, then parse it
	If Not showPriceParam Is Nothing Then
		
		If Not Boolean.TryParse(showPriceParam.ToString, showPrice) Then
			showPrice = false
		End If

	End If
		
	
End Sub

Sub ActiveReport_NoData

	rpt.Cancel

End Sub

Function ActiveReport_FetchData(ByVal EOF As Boolean) As Boolean
    
      If Not EOF Then
          ' This will set the CurrentProposalItemLevel2 Property to for consumption by the report and/or sub reports
    	     ReportUtilities.SetCurrentProposalItemLevel2(rpt)
    	     Return False
      Else
    	     Return True
      End If
    

End Function
Sub grpItemHeader_Format


	' If we are showing the Model #, then set it, otherwise the control will use the default binding
	If showModel Then
		ReportUtilities.SetManufacturerModelTextBox(rpt,"grpItemHeader","txtManufacturer")
	End If
	
	ReportUtilities.SetControlTopPosition(rpt, "grpItemHeader", "txtDescription", "txtManufacturer", .02)
	
	Dim itm As DTools.SystemIntegrator.Reporting.Item = ReportUtilities.ReturnItem(rpt)
	Dim accessorizedPrice As Boolean = false
	
	' if the item is not null and we are showing price, check the value, otherwise false
	If itm IsNot Nothing And showPrice Then
		accessorizedPrice = itm.AccessorizedPrice
	End If

	' set the visibility of the label
	ReportUtilities.SetControlVisibility(rpt, "lblAccessorized", accessorizedPrice)

	' set the visibility of the price textbox
	ReportUtilities.SetControlVisibility(rpt, "txtInstallPrice",showPrice)
	
End Sub

Sub grpItemFooter_Format

	Dim itm As DTools.SystemIntegrator.Reporting.Item = ReportUtilities.ReturnItem(rpt)
	
	Dim accessorizedPrice As Boolean = false

	Dim itemHash As Integer = 0
	
	try
		itemHash = Ctype(ReportUtilities.ReturnTextBoxValue(rpt,"grpItemFooter","txtItemHash"), Integer)
	catch 
	End try
	
	ReportUtilities.SetCurrentProposalItemLevel2(itemHash)
	
	
	If itm IsNot Nothing Then
		accessorizedPrice = itm.AccessorizedPrice
		
		Select Case ReportUtilities.SummarizeEquipment
		
			Case 0 ' ShowAllDetail
		 		ReportUtilities.BindSubReport(rpt, "grpItemFooter", "subProposalLevel3Items")
		 		
		 	Case 1 ' ItemSetting
				If itm.Summarize Then
					ReportUtilities.UnBindSubReport(rpt, "grpItemFooter", "subProposalLevel3Items")
				Else
					ReportUtilities.BindSubReport(rpt, "grpItemFooter", "subProposalLevel3Items")
				End If
	
			Case 2 ' ShowNoDetail
				ReportUtilities.UnBindSubReport(rpt, "grpItemFooter", "subProposalLevel3Items")
				
		End Select
		
	End If


End Sub

'***************************************** New Function to get Unique list from the Node List **************************************
'Returns the unique list of values from the nodelist
    Private Function ReturnUniqueList(ByVal xmlNodeList As XmlNodeList) As List(Of String)

        Dim uniqueList As List(Of String) = New List(Of String)

        For Each node As XmlNode In xmlNodeList
            If Not (uniqueList.Contains(node.InnerText)) Then
                uniqueList.Add(node.InnerText)
            End If
        Next

        Return uniqueList

    End Function
    
   '*******************************************************************************************************************************************

- Publish the report


Proposal Main Report Changes -
- Create a Custom Report based on existing Proposal Report.
- Bind the new sub report –
1. Right click on the sub report “subProposalItemsLevel2” in “grpItemFooter” section.
Bind D-Tools Report.JPG
2. Then Click on the “Bind to D-Tools Report” menu item, it will show Published Report list dialog, there select the new customized sub report “Proposal – Sub report”.
- Publish the report.

Note – This sub report is specifically grouped by Phase. You can customize the report as per your need.


Hope it helps.
__________________
Narayana Karthik

Last edited by nkarthick; 08-07-2009 at 06:28 AM.
nkarthick 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Custom Report and Dynamic grouping bcharnz Reports and Reporting Center 4 12-03-2009 10:00 PM
Published report not showing in reports masonc Reports and Reporting Center 1 09-29-2009 02:18 PM
Report Center Crashing MatthewD Reports and Reporting Center 0 09-16-2008 09:35 PM
Inserting a contract report into Main report bcharnz Reports and Reporting Center 4 11-29-2007 08:21 PM
Same Man & Model, Different Description jpol Reports and Reporting Center 4 10-11-2007 03:31 PM


All times are GMT. The time now is 09:01 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.