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

Formatted Printing of RadGridView

4 Answers 107 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 24 Jun 2014, 08:12 AM
Hello,
I want to print/export the contents of a RadGridView. However, I want to retain the cell styles (or at least format it somewhat similar), especially for user-defined columns. For example, the number of decimal digits or the localized enum value should be retained.

When I use the ElementExporting event and check for e.Element == ExportElement.Cell,
the e.Context value points to the Column, not to the concrete cell. Is there any way to get the concrete GridViewCell? Or at least get the bound item?

Alex

 

4 Answers, 1 is accepted

Sort by
0
Alexander
Top achievements
Rank 1
answered on 24 Jun 2014, 10:17 AM
Okay - the reason is simply that for columns outside of the visible range, there simply dont exist any cells.
So the e.Context would be Null in this case.

As a workaround, I now determine the (formatted) cell content for myself from the column bindings.
0
Dimitrina
Telerik team
answered on 24 Jun 2014, 10:33 AM
Hello Alex,

Indeed, this is correct. You can also refer to the Export FAQ article.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Alexander
Top achievements
Rank 1
answered on 24 Jun 2014, 11:10 AM
Thanks for the affirmation.
Just another question: is there any way to control the layout of the columns?
For example, reduce the page margin and increase the spacing between the individual columns.
At the moment, the columns appear so squeezed...

Alex
0
Dimitrina
Telerik team
answered on 24 Jun 2014, 02:17 PM
Hello Alex,

The columns appear as squeezed as they are still not realized and measured.
One way would be to style the exported data setting the e.Styles dictionary with proper CSS values when the ElementExporting is raised for the RadGridView. You can refer to the "Exporting" demo for an example.

As another approach you can check our new formatting options introduced together with Async Export. You can specifically check the article on ExportFormat.Html.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Alexander
Top achievements
Rank 1
Answers by
Alexander
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or