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

[Solved] Printing a grid

5 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Stéphan Parrot
Top achievements
Rank 1
Stéphan Parrot asked on 22 Apr 2011, 06:23 PM
Hello folks,
      We're using a grid on a page where the user can hit ctrl+p or push a button that calls a javascript (window.print()) to print the page and the grid. We have a few glitches with how the grid gets rendered on paper:

- In our case, we use the footer to display a summary and, when the grid spans on several pages, we get the footer with the grand total printed on EVERY pages and on the last one as well...
Plus, the last row of the first page and all subsequent pages and the top row of all pages after the first one are missing but on screen, everything is there...
This is happening in IE 8.
In Firefox, it only shows the first page but prints as many pages as in IE8 but they're blank...
We cannot go back and remove the grid component to use another one but we cannot cut the print feature either... Does anyone have experienced this before? Is there a way to fix this?

Thanks... 

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 25 Apr 2011, 07:30 AM
Hello Stéphan Parrot,

Browsers may experience trouble when printing complex web pages and that's why a print stylesheet may be required in your case. Can you send us a sample running project which shows your grid configuration? We will test locally to see what is broken during printing. 

All the best,
Atanas Korchev
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
0
Stéphan Parrot
Top achievements
Rank 1
answered on 26 Apr 2011, 02:58 PM
Hi Atanas, 
I cannot send you the application's actual code so, I'm trying to build a sample project which uses the same grid configuration. 
But, as I'm doing so, I have a VERY strange behavior when the grid renders at runtime...
If I do no debug and step in the item's generation loop, ALL my items shows the very same data as the first item. If I trace my code step by step and inspect each items, THEN and only THEN, it gets displayed properly...
Anything on this on your side?
0
Atanas Korchev
Telerik team
answered on 26 Apr 2011, 03:02 PM
Hi Stéphan Parrot,

 I cannot be sure without seeing the item generation code. The grid does not have such a problem as far as I know - it displays the data which it is bound to.

Regards,
Atanas Korchev
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
0
Stéphan Parrot
Top achievements
Rank 1
answered on 26 Apr 2011, 04:09 PM
Hi Atanas, 
I've fixed the issue related to the data not being unique. For the record and to maybe help anyone else, here's why and how I fixed this:
I'm using the Random class to generate unique values for my objects for this sample since I'm not gonna put a database and all the heavy stuff in. But the Random class relies on the current machine's datatime value so, as it's executing the code at lightning speeds, it uses the very same value for calculating the next random value.
To fix this, I've added a Thread.Sleep(5) 5 milliseconds to let the value change for the next value ensuring uniqueness. 1 ms wasn't enough as in some cases, I was still getting some duplicated contiguous values.

So, now, here's my sample project in hope you will be experiencing the same issues...

Thanks for the help!
0
Dimo
Telerik team
answered on 27 Apr 2011, 01:43 PM
Hello Stéphan,

A short research revealed that browsers print table footers on every page and this is the expected behavior.

If you require to have the footer content on the last page only, you should add it to another container instead, for example in a toolbar placed at the bottom of the Grid.

Html.Telerik().Grid(Model)
        .Name("Grid")
        .ToolBar(toolBar => toolBar.Position(GridToolBarPosition.Bottom).........

http://demos.telerik.com/aspnet-mvc/grid/customtoolbar


I did not reproduce the problem with empty printed pages in Firefox or the missing rows in IE.

Regards,
Dimo
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
Grid
Asked by
Stéphan Parrot
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Stéphan Parrot
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or