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

RadGridView does not export 'custom' datatemplate columns

3 Answers 81 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Donald Hamm
Top achievements
Rank 1
Donald Hamm asked on 05 Mar 2010, 04:45 PM
I have a RadGridView with a custom column:

<telerikGridView:RadGridView.Columns>
<telerikGridView:GridViewColumn Header="BatchStatus" UniqueName="NCD_Link">
<telerikGridView:GridViewColumn.CellTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="185"/>
<ColumnDefinition Width="125"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock x:Name="StatusDesc" FontFamily="Verdana" FontSize="12" FontWeight="Bold" Foreground="#FF1B109C" Margin="0, 0, 3, 5" Grid.Row="0" Grid.Column="0" Text="{Binding StatusDesc}" Grid.ColumnSpan="3" />
<TextBlock x:Name="FileName" FontFamily="Verdana" FontSize="10" Foreground="Black" Margin="0, 0, 50, 0" Grid.Row="1" Grid.Column="0" Text="{Binding ImportFileName}" />
<TextBlock x:Name="Cost" FontFamily="Verdana" FontSize="10" Foreground="Red" Margin="10, 0, 15, 0" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Text="{Binding Cost, Converter={StaticResource MoneyConverter}, ConverterParameter=d}" />
<TextBlock x:Name="PostDate" FontFamily="Verdana" FontSize="10" Foreground="Green" Margin="10, 0, 26, 5" Grid.Row="1" Grid.Column="2" Text="{Binding PostDate, Converter={StaticResource DateConverter}, ConverterParameter=d}" />
</Grid>
</DataTemplate>
</telerikGridView:GridViewColumn.CellTemplate>
</telerikGridView:GridViewColumn>
</telerikGridView:RadGridView.Columns>

The issue is when I export, I get rows, but no cells.  I've overridded the export function to actually 'create' string, but I don't get the 'cell' type, just the row type:

private void GridImportStatus_Exporting( object sender, Telerik.Windows.Controls.GridViewExportEventArgs e )
{
if( e.Element == Telerik.Windows.Controls.ExportElement.Row )
{
if( e.Value != null )
{
ServiceAsset.BatchImportStatusReport reportItem = e.Value as ServiceAsset.BatchImportStatusReport;
if( reportItem != null )
{
StringBuilder sb = new StringBuilder();
sb.Append( reportItem.StatusDesc + "<br/>" );

sb.AppendLine( reportItem.ImportFileName + "&tab;" +
String.Format( "{0:c}", reportItem.Cost ) + "&tab;" +
reportItem.PostDate.ToShortDateString() );
e.Value = "<td>" + sb.ToString() + "</td>";
}
}
}
}

so, what is the best way to get export to show a 'cell' of data, when I use a 'custom' data template?

-Don

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Mar 2010, 10:30 AM
Hi Don,

You can check if e.Element == ExportElement.Cell and set desired value to e.Value. More info can be found on this demo:
http://demos.telerik.com/silverlight/#GridView/Exporting

Greetings,
Vlad
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
Donald Hamm
Top achievements
Rank 1
answered on 15 Mar 2010, 02:50 PM
Thanks for the reply!

The issue I'm having is I never 'get' the element of type 'cell'.  I get Header, Table, Row, but Cell never comes.

Here is what I had before I set it to row:

        /// <summary>
        /// Handles the Exporting event of the GridImportStatus control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Windows.Controls.GridViewExportEventArgs"/> instance containing the event data.</param>
        private void GridImportStatus_Exporting( object sender, Telerik.Windows.Controls.GridViewExportEventArgs e )
        {
            if( e.Element == ExportElement.Cell )
            {
                if( e.Value != null )
                {
                    ServiceAsset.BatchImportStatusReport reportItem = e.Value as ServiceAsset.BatchImportStatusReport;
                    if( reportItem != null )
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.Append( reportItem.StatusDesc + "<br/>" );

                        sb.AppendLine( reportItem.ImportFileName + "&tab;" +
                                       String.Format( "{0:c}", reportItem.Cost ) + "&tab;" +
                                       reportItem.PostDate.ToShortDateString() );
                        e.Value = "<td>" + sb.ToString() + "</td>";
                    }
                }
            }
        }



When I set a breakpoint on e.Value != null, it never gets triggered.  If I set a breakpoint on e.Element == ExportElement.Cell and check each break, Cell is never an option.  So the issue is, when I use the templates I have listed in the XAML, I never get a 'Cell'...

-Don
0
Vlad
Telerik team
answered on 18 Mar 2010, 11:00 AM
Hello Don,

Please check this column to GridViewDataColumn - currently the grid export will loop only data columns.

Regards,
Vlad
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
GridView
Asked by
Donald Hamm
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Donald Hamm
Top achievements
Rank 1
Share this question
or