Export to excel of Hierarchical Grid view

3 posts, 0 answers
  1. Koti
    Koti avatar
    8 posts
    Member since:
    Jul 2012

    Posted 17 Aug 2012 Link to this post

    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. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 17 Aug 2012 Link to this post

    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.

  3. Koti
    Koti avatar
    8 posts
    Member since:
    Jul 2012

    Posted 17 Aug 2012 Link to this post

    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.
Back to Top