This is a migrated thread and some comments may be shown as answers.

Reset the page number by report group

1 Answer 284 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tan
Top achievements
Rank 1
Tan asked on 09 Jun 2010, 11:23 AM
I am using Telerik Reporting 2009 Q2 version. In my report, I need to reset the page number by report group.
I had been looking for the solution few days.
In the forum, referring to (http://www.telerik.com/community/forums/reporting/telerik-reporting/having-a-pagecount-on-grouping.aspx)
Mr Steve said, Telerik don't have such feature.

But, is there any work around to have it?

I actually did write a function for it. But still not able to get the result as I want.  Below is the function:

 private void ghDO_ItemDataBound(object sender, EventArgs e) 
        { 
                    
            //Get the group section object from sender 
            Telerik.Reporting.Processing.GroupSection groupSection = (Telerik.Reporting.Processing.GroupSection)sender; 
 
            //From the group section object get the current DataRow 
            System.Data.DataRow row = (System.Data.DataRow)groupSection.DataObject.RawData; 
 
            //If Previous DO is not equal to current DO. Page Number reset to 1. 
            if (OldDO != null && OldDO != groupSection.DataObject["do_no"].ToString()) 
            { 
               
                pageNumber = 1; 
            } 
            else  
            {   
                pageNumber = pageNumber + 1;  
            } 
             
            OldDO = groupSection.DataObject["do_no"].ToString(); 
            pageNo.Value = pageNumber.ToString();           
             
        } 
In my report, I define the page number as 1 in the text box by default.
When I preview the report, I keep getting page number = 1 even thought a DO is print in 2 pages.
Where is my mistake? Or, the function above totally won't be working?

 

1 Answer, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 14 Jun 2010, 06:31 PM
Hi Tan,

The only solution is use different report instances for each group (e.g. one report definition with one group data) and the ReportBook as described in the other thread. In this way you will be able to control the paging through the PageNumberingStyle property of the Report.

Your workaround is not possible as the ItemDataBinding and ItemDataBound events are raised during the report processing stage and are called only once for each group. Paging is performed later during the actual report rendering. This is the reason why page number always stays to 1. It is just because you always have a different group header when the method is called.

Hope this information helps.

All the best,
Chavdar
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Tan
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Share this question
or