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

[Solved] Export with custom header

2 Answers 121 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Christian
Top achievements
Rank 1
Christian asked on 27 Nov 2009, 07:36 PM
I have a grid with columns with a custom header to allow wrapping.  But when I export to html, it prints the header type like this :

Département Classe System.Windows.Controls.TextBlock Telerik.Windows.Controls.GridView.AlignmentContentPresenter

Here's the grid : (didn't put the column with an AligmentContentPresenter)
        <telerik:RadGridView Grid.Row="1" x:Name="gridView" CanUserFreezeColumns="true" CanUserInsertRows="False"   
                                 RowIndicatorVisibility="Collapsed" 
                                EnableColumnVirtualization="False" 
                             CanUserReorderColumns="False" 
                                FrozenColumnCount="2" 
                                AutoGenerateColumns="False" 
                              EditTriggers="CellClick" 
                             > 
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Department.Description}"   
                                            Header="Département" 
                                            IsReadOnly="True" 
                                            /> 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Class.Description}"   
                                            Header="Classe" 
                                            IsReadOnly="True" 
                                            > 
                </telerik:GridViewDataColumn> 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding GraduatedDate}"   
                                            Width="87" 
                                            IsReadOnly="True" 
                                            > 
                    <telerik:GridViewDataColumn.Header> 
                        <TextBlock   
                            TextWrapping="Wrap"   
                            Text="Graduation Date"/>  
                    </telerik:GridViewDataColumn.Header> 
                </telerik:GridViewDataColumn> 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 
 

Is this a bug or is there something else I need to do ?

2 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 30 Nov 2009, 07:15 AM
Hello,

You can handle this scenario easily using Exporting event. Just cast e.Value to TextBlock and get the Text property:

        private void RadGridView1_Exporting(object sender, GridViewExportEventArgs e)
        {
            if (e.Value is TextBlock)
            {
                e.Value = ((TextBlock) e.Value).Text;
            }
        }

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Christian
Top achievements
Rank 1
answered on 30 Nov 2009, 06:07 PM
Thanks, works like a charm!
Tags
GridView
Asked by
Christian
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Christian
Top achievements
Rank 1
Share this question
or