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

Get page number in code

3 Answers 320 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Koen
Top achievements
Rank 1
Koen asked on 03 Feb 2012, 02:58 PM
For our customer we need to print a patients' medical file with appointments. This has some legal implications like every appointment should get assigned a page number in the file which cannot change once assigned.

So what we need to do is to retrieve the page number in code and update the database and then ensure that every time the report is generated the page number remain the same (the data won't change once the page number has been assigned). Also the height of each data row can be variable depending on the medical information applied by the doctor. Can Telerik Reporting do this?

We would use the Silverlight ReportViewer.

3 Answers, 1 is accepted

Sort by
0
IvanY
Telerik team
answered on 07 Feb 2012, 06:01 PM
Hi Koen,

From your explanation it is not very clear what you are trying to achieve - we will need additional information to advise you accordingly.

Where are you going to use the PageNumber? Why do you need to ensure that the PageNumber is the same if the data will not change once the PageNumber is assigned? If the data will not change how the height of the data row will vary?

Greetings,
IvanY
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Koen
Top achievements
Rank 1
answered on 08 Feb 2012, 10:45 AM
The main problem is that we need a hook in code to retrieve which record is generated on which page or whenever a new page starts. If that is possible somehow we can use Telerik I guess.

There is a legal restriction that we should assign an ongoing page number to each record. When one would print the whole file these page numbers will correspond with the real page numbers of that report. But most of the time someone is only going to print a specific page. So you have to think of the page number as data and nog a built-in function of the report because when I want to print page 34 that is only going to return one page and the page number function would return "1". I know all that is possible with Telerik, just a where clause to filter on page number and using the page number data field in the header.

However when we print new pages (at the end of the whole file) with the latest new records which don't yet have a page number assigned we need to know where a new page starts so we can continue our count in the database. One of the features that we need to provide is "print new pages" which will start from the page that the first record without a page number is on. Usually there will be older items on the same page and that first record will get the same page number. Then during generation some record may start on the next page and then we need to increase our page number for those records. In the rare case that the last "counted" page is full and the new items would start on a new page it is ok if the previous page is still generated...

I hope that's more clear to you...
0
IvanY
Telerik team
answered on 09 Feb 2012, 06:17 PM
Hi Koen,

Currently if you print a specific page it will keep the numbering, meaning that if the PageNumber in the viewer will be printed on the sheet as well (if you print page number 34 on the sheet it will be also 34). So this scenario is already covered by default.

If you have some requirement or a data set that has to be divided in groups, what you can do is reset the PageNumber on each new Report Group - you can find more information in that Reset PageNumber per Report Group blog post.

You can store the page numbers in your database using the code provided in the above blog post. Additionally with a few modifications you can just count the pages and record them to a database without resetting them.

In order to provide "print new pages" functionality you will have to compare the page count in your database with the page count of the rendered report; In this scenario however you must ensure that all the new information is at the bottom of the report - your queries have to be ordered by ID or by some other ascending numeric value. Any other sorting, grouping or querying without ORDER BY may move the new data to an "old" page. You also must have in mind that paging is specific for each rendering media - this means that depending on the media the page count would/can be different.

All the best,
IvanY
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
General Discussions
Asked by
Koen
Top achievements
Rank 1
Answers by
IvanY
Telerik team
Koen
Top achievements
Rank 1
Share this question
or