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

Export to excel of Hierarchical Grid view

2 Answers 65 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Koti
Top achievements
Rank 1
Koti asked on 17 Aug 2012, 05:52 AM
Hi,
I have grid view with multiple hierarchies.
I need to export the data of parent grid view and child grid view data.
When i tried, able to export only parent grid data only.
The following is the design on of hierarchical grid view.
<telerik:RadGridView Grid.Row="1" x:Name="radJobDetails" telerik:StyleManager.Theme="Summer" ShowGroupPanel="False" Height="400" ItemsSource="{Binding service}" EnableColumnVirtualization="False"
                             RowStyle="{StaticResource radGridRow}" AlternateRowStyle="{StaticResource radGridAltRow}" AlternationCount="2"  AutoGenerateColumns="False"
                             RowIsExpandedChanged="radJobDetails_RowIsExpandedChanged" ElementExported="radJobDetails_ElementExported">
                <telerik:RadGridView.ChildTableDefinitions>
                    <telerik:GridViewTableDefinition>
                        <telerik:GridViewTableDefinition.Relation>
                            <telerik:PropertyRelation ParentPropertyName="uaudioid"></telerik:PropertyRelation>
                        </telerik:GridViewTableDefinition.Relation>
                    </telerik:GridViewTableDefinition>
                </telerik:RadGridView.ChildTableDefinitions>
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding uaid}" Header="AID" Width="100" IsReadOnly="True"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding uaname}" Header="AName" Width="300" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding ufname}" Header="FName"  Width="300"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding ums}" Header="Mins"  Width="100"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding ulcnt}" Header="LCount"  Width="100"/>
                </telerik:RadGridView.Columns>
                <telerik:RadGridView.HierarchyChildTemplate>
                    <DataTemplate x:Name="useraudioprivilages">
                        <telerik:RadGridView x:Name="radUserPrivilageActions" AutoGenerateColumns="False" ShowGroupPanel="False" ItemsSource="{Binding service}"
                                         RowStyle="{StaticResource radGridRow}" AlternateRowStyle="{StaticResource radGridAltRow}" AlternationCount="2" Loaded="radUserPrivilageActions_Loaded">
                            <telerik:RadGridView.Columns>
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding afilename}" Header="AFName" Width="300" />
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding auname}" Header="UName"  Width="150"/>
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding aadtime}" Header="Assigned Time"  Width="150"/>
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding awpname}" Header="Privilage"  Width="200"/>
                            </telerik:RadGridView.Columns>
                        </telerik:RadGridView>
                    </DataTemplate>
                </telerik:RadGridView.HierarchyChildTemplate>
            </telerik:RadGridView>

The following is the Export to Excel button functionality
private void btnExportToExcel_Click(object sender, RoutedEventArgs e)
{
    ExportFormat format = ExportFormat.ExcelML;
    bool? dialogResult = this.dialog.ShowDialog();
    if (dialogResult == true)
    {
        radpageruserwiseaudios.PageSize = 0;
        using (Stream stream = dialog.OpenFile())
        {
            GridViewExportOptions exportOptions = new GridViewExportOptions();
            exportOptions.Format = format;                   
            exportOptions.ShowColumnFooters = true;
            exportOptions.ShowColumnHeaders = true;
            exportOptions.ShowGroupFooters = true;                   
            radJobDetails.Export(stream, exportOptions);
        }
        radpageruserwiseaudios.PageSize = 10;
    }
}

Please give me a solution for exporting all the data.

2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 17 Aug 2012, 05:54 AM
Hello,

 Please check how this is done on our "Exporting RowDetails" online demo.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Koti
Top achievements
Rank 1
answered on 17 Aug 2012, 10:28 AM
Hi Didie,
The online demo is done based declaring the child grid in data template in grid.resource. But i have hierarchical grid views  up to 4 levels. I need to export all the data in this case.
Regards,
Koti.
Tags
GridView
Asked by
Koti
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Koti
Top achievements
Rank 1
Share this question
or