开发者

Telerik RadGrid doesn't seem to export Grouped data

Hi I've got a DNN application using Telerik RadGrid. We're exporting some data from the Grid but when we drill down on the grid control and export the data we only see the initial top level data, never the updated Grid. Here's my table tag and supporting code. I'm not an expert in ASPX/C#so please forgive my newbie-ness.

<mastertableview autogeneratecolumns="False" datakeynames="AccountId" datasourceid="SqlDataSource1"
    groupsdefaultexpanded="False">

    <DetailTables>
        <telerik:GridTableView runat="server" DataKeyNames="StatementId" DataSourceID="SqlDataSource2"
            Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
            Font-Underline="False" >
            <DetailTables>
                <telerik:GridTableView runat="server" DataSourceID="SqlDataSource3" Font-Bold="False"
                    Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False"
                    GroupsDefaultExpanded="False" ShowFooter="True" ShowGroupFooter="True" AllowMultiColumnSorting="True"
                    GridLines="None">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="StatementId" MasterKeyField="StatementId" />
                    </ParentTableRelation>

                    <AlternatingItemStyle BackColor="White" Font-Bold="False" Font-Italic="False" Font-Overline="False"
                        Font-Strikeout="False" Font-Underline="False" Wrap="True" />
                    <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                        Font-Underline="False" Wrap="True" />
                    <FooterStyle BackColor="Yellow" Font-Bold="False" Font-Italic="False" Font-Overline="False"
                        Font-Strikeout="False" Font-Underline="False" Wrap="True" />
                </telerik:GridTableView>
            </DetailTables>
            <ParentTableRelation>
                <telerik:GridRelationFields DetailKeyField="AccountId" MasterKeyField="AccountId" />
            </ParentTableRelation>
            <CommandItemSettings ExportToPdfText="Export to Pdf" />
            <ExpandCollapseColumn Visible="True">
            </ExpandCollapseColumn>
        </telerik:GridTableView>
    </DetailTables>
    <ParentTableRelation>
        <telerik:GridRelationFields DetailKeyField="AccountId" MasterKeyField="AccountId" />
    </ParentTableRelation>

    <ExpandCollapseColumn Visible="True">
    </ExpandCollapseColumn>
    <Columns>
        <telerik:GridBoundColumn DataField="ACCOUNTID" DataType="System.Int32" HeaderText="ACCOUNTID"
            SortExpression="ACCOUNTID" UniqueName="ACCOUNTID">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="ACCOUNTREF" HeaderText="ACCOUNTREF" SortExpression="ACCOUNTREF"
            UniqueName="ACCOUNTREF">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="CUSTOMERID" DataType="System.Int32" HeaderText="CUSTOMERID"
            SortExpression="CUSTOMERID" UniqueName="CUSTOMERID">
        </telerik:GridBoundColumn>
    </Columns>
</mastertableview>

The exports are registered with the script manager on load :

protected void Page_Load(object send开发者_运维知识库er, EventArgs e)
{
    Button2.Enabled = Session[UserSelection.SelectedValue] != null ? true : false;
    ScriptManager.GetCurrent(Page).RegisterPostBackControl(Button3); 
    ScriptManager.GetCurrent(Page).RegisterPostBackControl(Button4); 
}

and I' calling the Export with the following :

protected void Button3_Click(object sender, System.EventArgs e)
    {
        //ConfigureExport();
       RadGrid1.Rebind();
       RadGrid1.ExportSettings.FileName = "RadGridExportToExcel";
       RadGrid1.ExportSettings.ExportOnlyData = true;
       RadGrid1.ExportSettings.OpenInNewWindow = true;

        RadGrid1.MasterTableView.ExportToExcel();
    }

Can anyone see what I'm missing, apart from DNN/ASPX experience and the will to live :)


Solved: but not completely... By adding the following

RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;

to the button_click event eg:

protected void Button3_Click(object sender, System.EventArgs e)
    {
        //ConfigureExport();
       RadGrid1.Rebind();
       RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
       RadGrid1.ExportSettings.FileName = "RadGridExportToExcel";
       RadGrid1.ExportSettings.IgnorePaging = true;
       RadGrid1.ExportSettings.ExportOnlyData = true;
       RadGrid1.ExportSettings.OpenInNewWindow = true;

        RadGrid1.MasterTableView.ExportToExcel();
    }

Although this just gives the first level grouping, no sub groups. Also it doesn't just export the drill down data you selected but just an expanded view of the entire grid to the first level... Finally, to get the tertiary detail table working you can add

RadGrid1.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true;

This threw an OOM error in DNN for me :

A critical error has occurred.
Exception of type 'System.OutOfMemoryException' was thrown.

I'm guessing you'd have to do some sort of event processing and manually open the data in a modal window and export that instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜