Telerik RadGrid 似乎无法导出分组数据

发布于 2024-10-10 14:35:56 字数 4022 浏览 7 评论 0原文

您好,我有一个使用 Telerik RadGrid 的 DNN 应用程序。我们正在从网格导出一些数据,但是当我们深入网格控件并导出数据时,我们只能看到初始的顶级数据,而看不到更新的网格。这是我的表标签和支持代码。我不是 ASPX/C# 方面的专家,所以请原谅我的新手。

<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>

导出在加载时向脚本管理器注册:

protected void Page_Load(object sender, EventArgs e)
{
    Button2.Enabled = Session[UserSelection.SelectedValue] != null ? true : false;
    ScriptManager.GetCurrent(Page).RegisterPostBackControl(Button3); 
    ScriptManager.GetCurrent(Page).RegisterPostBackControl(Button4); 
}

并且我使用以下内容调用导出:

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();
    }

除了 DNN/ASPX 经验和生存意愿之外,任何人都可以看到我缺少的内容吗:)

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 sender, 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 :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨离汐 2024-10-17 14:35:56

已解决:但不完全...通过将以下内容添加

RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;

到button_click事件中,例如:

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();
    }

虽然这只是给出了第一级分组,但没有子组。此外,它不仅导出您选择的向下钻取数据,还只是将整个网格的扩展视图扩展到第一级...最后,要使第三级详细信息表正常工作,您可以添加

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

这对我来说在 DNN 中引发了 OOM 错误:

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

我猜您必须进行某种事件处理并在模式窗口中手动打开数据并将其导出。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文