1. 程式人生 > >DEVexpress控件使用 ASPxGridView 制作報表帶子表的 備忘

DEVexpress控件使用 ASPxGridView 制作報表帶子表的 備忘

pan ... color row settings tail grouping column exporter

利用ASPxGridView制作報表
<dx:ASPxGridView ID="grdProductivity" runat="server" AutoGenerateColumns="False" KeyFieldName="Work_Cell_Code" SkinID="ASPxGridViewSkin"
OnDetailRowExpandedChanged="grdProductivity_DetailRowExpandedChanged"    //子表展開時觸發
OnCustomUnboundColumnData="grdProductivity_OnCustomUnboundColumnData"    //動態序號添加

OnPageIndexChanged="grdProductivity_OnPageIndexChanged"
OnPageSizeChanged="grdProductivity_OnPageSizeChanged"
OnBeforeColumnSortingGrouping="grdProductivity_OnBeforeColumnSortingGrouping"   //點擊列排序 發生拖拽時觸發
OnCustomColumnGroup="grdProductivity_OnCustomColumnGroup"
OnCustomColumnSort="grdProductivity_OnCustomColumnSort">
<Columns>
<dx:GridViewDataTextColumn VisibleIndex="0" Caption="序號" FieldName="hh" UnboundType="Integer" Name="hh" Width="5px">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn VisibleIndex="1" FieldName="Production_Line_Desc" Caption="生產線名稱">
</dx:GridViewDataTextColumn> </Columns>
<Styles>
<Header ForeColor="#697a8a" Font-Bold="True" Font-Size="15px" BackColor="#EFF2F7" Border-BorderColor="#e3eae7"></Header>
</Styles>
<SettingsDetail ShowDetailRow="True"></SettingsDetail>
<Templates>
<DetailRow>
<dx:ASPxGridView runat="server" ID="gv_detail" AutoGenerateColumns="false" SkinID="DetailASPxGridViewSkin" OnCustomUnboundColumnData="gv_detail_OnCustomUnboundColumnData">
<Columns>
<dx:GridViewDataTextColumn VisibleIndex="0" FieldName="hh" Caption="序號" UnboundType="Integer" Name="hh" Width="5px">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn VisibleIndex="1" FieldName="Production_Line_Desc" Caption="生產線名稱">
</dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>
</DetailRow>
</Templates> </dx:ASPxGridView>
<dx:ASPxGridViewExporter ID="dxgvExport" runat="server" GridViewID="grdProductivity"></dx:ASPxGridViewExporter> / /導出到xlsx
主子表:報表 主表ID: <dx:ASPxGridView ID="grdProductivity"...> 子表ID: <dx:ASPxGridView ID="gv_detail"...> 加子表時,一定要加上以下代碼: <SettingsDetail ShowDetailRow="True"></SettingsDetail>
<Templates>
<DetailRow> 顯示的列:<Columns>
<dx:GridViewDataTextColumn VisibleIndex="0" FieldName="hh" Caption="序號" UnboundType="Integer" Name="hh" Width="5px">
</dx:GridViewDataTextColumn>           <dx:GridViewDataTextColumn VisibleIndex="1" FieldName="Production_Line_Desc" Caption="生產線名稱">
</dx:GridViewDataTextColumn>      </Columns> //其中FieldName一定是sql查出來的字段,顯示的列名為:Caption="生產線名稱" 設置標題的樣式;
     <Styles>
<Header ForeColor="#697a8a" Font-Bold="True" Font-Size="15px" BackColor="#EFF2F7" Border-BorderColor="#e3eae7"></Header>
</Styles>

DEVexpress控件使用 ASPxGridView 制作報表帶子表的 備忘