DEVexpress控制元件使用 ASPxGridView 製作報表帶子表的 備忘
阿新 • • 發佈:2018-11-24
利用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>
<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
<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>