原创|其它|编辑:郝浩|2012-10-08 10:35:48.000|阅读 766 次
概述:本文演示了如何使用含有ASPxGridView的ASPxPopupControl 控件实现一个向下钻取的主从报表。
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
本文演示了如何使用含有ASPxGridView的ASPxPopupControl 控件实现一个向下钻取的主从报表。
其要点包括:
1.XRLabel.HtmlItemCreated 事件是用于通过e.ContentCell.InnerHtml 参数创建一个带有href='javascript:.属性的 html 超链接。该链接将引发一个更新具体数据的特殊脚本功能。
2.XRLabel.Tag属性被绑定到主数据表的ID字段。这使得我们能够通过e.Brick.Value这个参数获取到XRLabel.HtmlItemCreated事件处理程序中的ID。
3. 通过ASPxClientGridView.PerformCallback()的方式,ASPxGridView的更新过程将不能从客户端编辑。
4.ASPxPopupControl.ShowAtElement()方法被调用来显示ASPxPopupControl。
VB.NET
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %> <%@ Register Assembly="DevExpress.XtraReports.v11.1.Web, Version=11.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.XtraReports.Web" TagPrefix="dxxr" %> <%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %> <%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %> <%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="//www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <script language="javascript" type="text/javascript"> function UpdateProductsInfo(categoryId) { var element = document.getElementById('cat' + categoryId); gridView.PerformCallback(categoryId); popupControl.ShowAtElement(element); } </script> </head> <body> <form id="form1" runat="server"> <div> <dxpc:ASPxPopupControl ID="ASPxPopupControl1" runat="server" ClientInstanceName="popupControl" Width="407px" BackColor="#FFFF99" FooterText="" HeaderText="Products list" PopupHorizontalOffset="20" PopupVerticalOffset="20"> <ClientSideEvents Init="function(s, e) { //popupControl.ShowAtPos(100, 100); }" /> <ContentCollection> <dxpc:PopupControlContentControl runat="server"> <dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" Width="413px" ClientInstanceName="gridView" OnCustomCallback="ASPxGridView1_CustomCallback"> <Columns> <dxwgv:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="0"> </dxwgv:GridViewDataTextColumn> <dxwgv:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="1"> </dxwgv:GridViewDataTextColumn> <dxwgv:GridViewDataTextColumn FieldName="UnitsInStock" VisibleIndex="2"> </dxwgv:GridViewDataTextColumn> </Columns> <SettingsPager PageSize="5"> </SettingsPager> </dxwgv:ASPxGridView> </dxpc:PopupControlContentControl> </ContentCollection> <HeaderStyle BackColor="#FF99CC" Font-Bold="True" Font-Size="Large" /> <Border BorderColor="#6666FF" /> </dxpc:ASPxPopupControl> <br /> <dxxr:ReportToolbar ID="ReportToolbar1" runat="server" ShowDefaultButtons="False" ReportViewer="<%#ReportViewer1%>"> <Items> <dxxr:ReportToolbarButton ItemKind="Search" ToolTip="Display the search window" /> <dxxr:ReportToolbarSeparator /> <dxxr:ReportToolbarButton ItemKind="PrintReport" ToolTip="Print the report" /> <dxxr:ReportToolbarButton ItemKind="PrintPage" ToolTip="Print the current page" /> <dxxr:ReportToolbarSeparator /> <dxxr:ReportToolbarButton Enabled="False" ItemKind="FirstPage" ToolTip="First Page" /> <dxxr:ReportToolbarButton Enabled="False" ItemKind="PreviousPage" ToolTip="Previous Page" /> <dxxr:ReportToolbarLabel Text="Page" /> <dxxr:ReportToolbarComboBox ItemKind="PageNumber" Width="65px"> </dxxr:ReportToolbarComboBox> <dxxr:ReportToolbarLabel Text="of" /> <dxxr:ReportToolbarTextBox IsReadOnly="True" ItemKind="PageCount" /> <dxxr:ReportToolbarButton ItemKind="NextPage" ToolTip="Next Page" /> <dxxr:ReportToolbarButton ItemKind="LastPage" ToolTip="Last Page" /> <dxxr:ReportToolbarSeparator /> <dxxr:ReportToolbarButton ItemKind="SaveToDisk" ToolTip="Export a report and save it to the disk" /> <dxxr:ReportToolbarButton ItemKind="SaveToWindow" ToolTip="Export a report and show it in a new window" /> <dxxr:ReportToolbarComboBox ItemKind="SaveFormat" Width="70px"> <Elements> <dxxr:ListElement Text="Pdf" Value="pdf" /> <dxxr:ListElement Text="Xls" Value="xls" /> <dxxr:ListElement Text="Rtf" Value="rtf" /> <dxxr:ListElement Text="Mht" Value="mht" /> <dxxr:ListElement Text="Text" Value="txt" /> <dxxr:ListElement Text="Csv" Value="csv" /> <dxxr:ListElement Text="Image" Value="png" /> </Elements> </dxxr:ReportToolbarComboBox> </Items> <Styles> <LabelStyle> <Margins MarginLeft="3px" MarginRight="3px" /> </LabelStyle> </Styles> </dxxr:ReportToolbar> <br /> <dxxr:ReportViewer ID="ReportViewer1" runat="server" onunload="ReportViewer1_Unload"> </dxxr:ReportViewer> </div> </form> </body> </html>
C#
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly="DevExpress.XtraReports.v11.1.Web, Version=11.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.XtraReports.Web" TagPrefix="dxxr" %> <%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %> <%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %> <%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="//www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <script language="javascript" type="text/javascript"> function UpdateProductsInfo(categoryId) { var element = document.getElementById('cat' + categoryId); gridView.PerformCallback(categoryId); popupControl.ShowAtElement(element); } </script> </head> <body> <form id="form1" runat="server"> <div> <dxpc:ASPxPopupControl ID="ASPxPopupControl1" runat="server" ClientInstanceName="popupControl" Width="407px" BackColor="#FFFF99" FooterText="" HeaderText="Products list" PopupHorizontalOffset="20" PopupVerticalOffset="20"> <ClientSideEvents Init="function(s, e) { //popupControl.ShowAtPos(100, 100); }" /> <ContentCollection> <dxpc:PopupControlContentControl runat="server"> <dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" Width="413px" ClientInstanceName="gridView" OnCustomCallback="ASPxGridView1_CustomCallback"> <Columns> <dxwgv:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="0"> </dxwgv:GridViewDataTextColumn> <dxwgv:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="1"> </dxwgv:GridViewDataTextColumn> <dxwgv:GridViewDataTextColumn FieldName="UnitsInStock" VisibleIndex="2"> </dxwgv:GridViewDataTextColumn> </Columns> <SettingsPager PageSize="5"> </SettingsPager> </dxwgv:ASPxGridView> </dxpc:PopupControlContentControl> </ContentCollection> <HeaderStyle BackColor="#FF99CC" Font-Bold="True" Font-Size="Large" /> <Border BorderColor="#6666FF" /> </dxpc:ASPxPopupControl> <br /> <dxxr:ReportToolbar ID="ReportToolbar1" runat="server" ShowDefaultButtons="False" ReportViewer="<%# ReportViewer1 %>"> <Items> <dxxr:ReportToolbarButton ItemKind="Search" ToolTip="Display the search window" /> <dxxr:ReportToolbarSeparator /> <dxxr:ReportToolbarButton ItemKind="PrintReport" ToolTip="Print the report" /> <dxxr:ReportToolbarButton ItemKind="PrintPage" ToolTip="Print the current page" /> <dxxr:ReportToolbarSeparator /> <dxxr:ReportToolbarButton Enabled="False" ItemKind="FirstPage" ToolTip="First Page" /> <dxxr:ReportToolbarButton Enabled="False" ItemKind="PreviousPage" ToolTip="Previous Page" /> <dxxr:ReportToolbarLabel Text="Page" /> <dxxr:ReportToolbarComboBox ItemKind="PageNumber" Width="65px"> </dxxr:ReportToolbarComboBox> <dxxr:ReportToolbarLabel Text="of" /> <dxxr:ReportToolbarTextBox IsReadOnly="True" ItemKind="PageCount" /> <dxxr:ReportToolbarButton ItemKind="NextPage" ToolTip="Next Page" /> <dxxr:ReportToolbarButton ItemKind="LastPage" ToolTip="Last Page" /> <dxxr:ReportToolbarSeparator /> <dxxr:ReportToolbarButton ItemKind="SaveToDisk" ToolTip="Export a report and save it to the disk" /> <dxxr:ReportToolbarButton ItemKind="SaveToWindow" ToolTip="Export a report and show it in a new window" /> <dxxr:ReportToolbarComboBox ItemKind="SaveFormat" Width="70px"> <Elements> <dxxr:ListElement Text="Pdf" Value="pdf" /> <dxxr:ListElement Text="Xls" Value="xls" /> <dxxr:ListElement Text="Rtf" Value="rtf" /> <dxxr:ListElement Text="Mht" Value="mht" /> <dxxr:ListElement Text="Text" Value="txt" /> <dxxr:ListElement Text="Csv" Value="csv" /> <dxxr:ListElement Text="Image" Value="png" /> </Elements> </dxxr:ReportToolbarComboBox> </Items> <Styles> <LabelStyle> <Margins MarginLeft="3px" MarginRight="3px" /> </LabelStyle> </Styles> </dxxr:ReportToolbar> <br /> <dxxr:ReportViewer ID="ReportViewer1" runat="server" onunload="ReportViewer1_Unload"> </dxxr:ReportViewer> </div> </form> </body> </html>
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn
文章转载自:DevExpress中文网