Print Page | Close Window

Subtotal in Xtreme Report?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=3568
Printed Date: 26 November 2024 at 11:28pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Subtotal in Xtreme Report?
Posted By: exycomm
Subject: Subtotal in Xtreme Report?
Date Posted: 27 January 2006 at 9:08am

Hi

How can make subtotals with this control?

thanks!




Replies:
Posted By: sserge
Date Posted: 28 January 2006 at 11:35am
Hi,

With the standard sample application, you can calculate and show subtotals for (for example) Price column with the following piece of code. Please note that you should add Price column onto "Group By" field to enable grouping.

int nCount = GetReportCtrl().GetRows()->GetCount();
for (int i = nCount - 1; i >= 0; i--)
{
     CXTPReportRow* pRow = GetReportCtrl().GetRows()->GetAt(i);
     if (pRow->IsGroupRow())
     {
           // calculate subtotals
           double dSubtotal = 0;
           CXTPReportRows* pChildren = pRow->GetChilds();
           for (int j = pChildren->GetCount() - 1; j >= 0; j--)
           {
                CXTPReportRow* pChild = pChildren->GetAt(j);
                CMessageRecordItemPrice* pItem = DYNAMIC_DOWNCAST(CMessageRecordItemPrice, pChild->GetRecord()->GetItem(COLUMN_PRICE));
                dSubtotal += pItem->GetValue();
           }
          
           // set caption
           CXTPReportGroupRow* pGroupRow = (CXTPReportGroupRow*)pRow;
           CString strSubtotal;
           strSubtotal.Format(_T("(Subtotal: %f)"), dSubtotal);
           pGroupRow->SetCaption(pGroupRow->GetCaption() + strSubtotal);
     }
}


--
WBR,
Serge


Posted By: Warren
Date Posted: 20 February 2006 at 9:48am
Serge,

I understand the posted code, but where do you suggest is the most appropriate place to add this an application?

Should I derive from the report control, and add it to the end of an overrriden virtual void Populate()


Posted By: sserge
Date Posted: 20 February 2006 at 11:55am
Hi Warren,

Of course it depends on your needs, but if you need subtotals to be always properly calculated, it would be a best solution... For example, after drag-n-drop to/from group area it would be the only way to have group row captions automatically updated.

--
WBR,
Serge



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net