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

Exporting to pdf and conditionally change text colour depending on a column value

3 Answers 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clive Hoggar
Top achievements
Rank 1
Clive Hoggar asked on 11 Apr 2017, 04:24 PM

Hi

I am exporting a radgrid to pdf and setting the background colour of alternate lines as light grey, font and font size for cells and footer in the item created event, and all is working as it should.

However I would like to change the text color or background color of a column based on the value of another column but I am not sure in which event I should do this while exporting to pdf. I tried the RadGrid1_ItemDataBound event but it has no effect on the pdf output. 

Can you point me in the right direction?

Thanks

 

 

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 14 Apr 2017, 08:11 AM
Hello Clive,

When exporting, the ItemDataBound event handler will be raised only when IgnorePaging exporting property is enabled. Otherwise, you can try using PreRender and traverse the RadGrid1.Items collection to achieve this requirement.

Further info about PDF exporting events you can find here:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/exporting/export-formats/pdf-export

I hope this will prove helpful.

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Clive Hoggar
Top achievements
Rank 1
answered on 14 Apr 2017, 02:07 PM

Hi Eyup

Thanks for this!

The itemdatabound event handler approach worked out fine for conditional formatting of an item.  

I subsequently had trouble hiding the column that i was using the value of to determine the text color of the ID column. When I tried to hide the column programmatically the text of the relevant ID items was no longer red.

However in the pdf exporting link you sent (above) I saw the new declarative 'Exportable="false"' setting for hiding columns in the generated pdf, and this did the job!

Thanks a lot

Clive

0
Eyup
Telerik team
answered on 19 Apr 2017, 08:33 AM
Hi Clive,

Another thing which you can help you when implementing custom exporting logic with RadGrid is the IsExporting property, which was recently introduced replace the necessity of using a global variable in the code-behind:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/exporting/export-formats/pdf-export#appearance

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Clive Hoggar
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Clive Hoggar
Top achievements
Rank 1
Share this question
or