Devexpress ASPxPivotGrid 按某列排序,以及把GrandTotal修改掉

<div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td align="center" style="color:#039" mce_style="color:#039" colspan=3><h3></h3></td></tr>
<tr><td width="40%"></td><td width="27%" align="center"style="color:#039"><h5>在冊罪犯總數:<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></h5></td><td width="33%"></td></tr>


<tr>
<td colspan=3>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ssodsn %>" SelectCommand="SELECT a.*,b.dept_name as sname,c.dept_name as dname FROM [dbo].[B_prinson] a inner join (select max(addtime) as addtime,deptid from B_prinson a group by deptid)m on a.addtime =m.addtime inner join B_department b on a.deptid=b.id inner join B_department c on a.deptidb=c.id order by a.autoid desc"></asp:SqlDataSource>

<dxwpg:ASPxPivotGrid ID="ASPxPivotGrid1" SortBySummaryInfo-SummaryType="Max" runat="server" CssClass="" DataSourceID="SqlDataSource1" OnCustomFieldSort="ASPxPivotGrid1_CustomFieldSort" Font-Bold="True" Font-Size="Medium" Width="100%" OnCustomSummary="ASPxPivotGrid1_CustomSummary">
<Styles CssFilePath="~/App_Themes/Glass/{0}/styles.css" CssPostfix="Glass">
<HeaderStyle BackColor="White">
<HoverStyle>
<BackgroundImage ImageUrl="~/App_Themes/Glass/PivotGrid/pgHeaderBackHot.gif" Repeat="RepeatX" />
</HoverStyle>
<BackgroundImage ImageUrl="~/App_Themes/Glass/PivotGrid/pgHeaderBack.gif" Repeat="RepeatX" />
</HeaderStyle>
<FilterAreaStyle>
<BackgroundImage ImageUrl="~/App_Themes/Glass/PivotGrid/pgFilterAreaBack.gif" Repeat="RepeatX" />
</FilterAreaStyle>
<FilterButtonPanelStyle>
<BackgroundImage ImageUrl="~/App_Themes/Glass/PivotGrid/pgFilterPanelBack.gif" Repeat="RepeatX" />
</FilterButtonPanelStyle>
<TotalCellStyle Font-Bold="True" ForeColor="Red">
</TotalCellStyle>
<GrandTotalCellStyle Font-Bold="True" Font-Size="14px" ForeColor="#003399">
</GrandTotalCellStyle>


</Styles>
<Fields>
<dxwpg:PivotGridField ID="field1" Area="RowArea" AreaIndex="0" Name="field1" FieldName="dname" GroupIndex="0" InnerGroupIndex="0" SortMode="Custom" >
<ValueStyle ForeColor="#003399" Font-Bold="True" Font-Size="13px">
</ValueStyle>



</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field2" Area="RowArea" AreaIndex="1" Name="field2" FieldName="sname" GroupIndex="0" InnerGroupIndex="1" SortMode="Custom">
<ValueStyle ForeColor="#003399" Font-Bold="True" Font-Size="13px" >
</ValueStyle>

</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field3" Area="DataArea" AreaIndex="0" Name="field3" FieldName="pnum1" Caption="在冊數">
<CellStyle HorizontalAlign="Center">
</CellStyle>
<ValueStyle ForeColor="#003399" Font-Bold="True" Font-Size="Medium" CssClass="tdwd">
</ValueStyle>


</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field4" Area="DataArea" AreaIndex="1" Caption="在押數" Name="field4" FieldName="pnum2">
<ValueStyle ForeColor="#003399" Font-Bold="True" Font-Size="Medium" CssClass="tdwd">
</ValueStyle> <CellStyle HorizontalAlign="Center">
</CellStyle>
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field5" Area="DataArea" AreaIndex="2" Caption="出工" Name="field5" FieldName="pnum3" >
<ValueStyle ForeColor="#003399" Font-Bold="True" Font-Size="Medium" CssClass="tdwd">
</ValueStyle> <CellStyle HorizontalAlign="Center">
</CellStyle>
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field6" Area="DataArea" AreaIndex="3" Caption="留監" Name="field6" FieldName="pnum4">
<ValueStyle ForeColor="#003399" Font-Bold="True" Font-Size="Medium" CssClass="tdwd">
</ValueStyle> <CellStyle HorizontalAlign="Center">
</CellStyle>
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field7" Area="DataArea" AreaIndex="4" Caption="禁閉" Name="field7" FieldName="pnum5" >
<ValueStyle ForeColor="#003399" Font-Bold="True" Font-Size="Medium" CssClass="tdwd">
</ValueStyle> <CellStyle HorizontalAlign="Center">
</CellStyle>
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field8" Area="DataArea" AreaIndex="5" Caption="嚴管" Name="field8" FieldName="pnum6">
<ValueStyle ForeColor="#003399" Font-Bold="True" Font-Size="Medium" CssClass="tdwd">
</ValueStyle> <CellStyle HorizontalAlign="Center">
</CellStyle>
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field9" Area="DataArea" AreaIndex="6" Caption="留醫" Name="field9" FieldName="pnum7">
<ValueStyle ForeColor="#003399" Font-Bold="True" Font-Size="Medium" CssClass="tdwd">
</ValueStyle> <CellStyle HorizontalAlign="Center">
</CellStyle>
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field10" Area="DataArea" AreaIndex="7" Caption="其餘" Name="field10" FieldName="pnum8">
<ValueStyle ForeColor="#003399" Font-Bold="True" Font-Size="Medium" CssClass="tdwd">
</ValueStyle><CellStyle HorizontalAlign="Center">
</CellStyle>
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field" Area="ColumnArea" AreaIndex="0" Name="field" >
<ValueTemplate>

<%-- <asp:Label ID="Label1" Width="600px" runat="server" Text="福州監獄當日罪犯分佈狀況" Font-Bold="true" ForeColor="red" Font-Size="15pt"></asp:Label>
--%>
</ValueTemplate>
<CellStyle Font-Bold="True" ForeColor="Red">
</CellStyle>
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field11" Area="RowArea" AreaIndex="2" FieldName="deptid"
Name="field11" Visible="False">
</dxwpg:PivotGridField>
<dxwpg:PivotGridField ID="field12" Area="RowArea" AreaIndex="3" FieldName="deptidb"
Name="field12" Visible="False">
</dxwpg:PivotGridField>

</Fields>
<EmptyAreaTemplate>0</EmptyAreaTemplate>
<Images ImageFolder="~/App_Themes/Glass/{0}/">
</Images>
<OptionsView ShowContextMenusForAllFieldValues="False" ShowColumnGrandTotals="False" ShowColumnHeaders="False" ShowDataHeaders="False" ShowFilterHeaders="False" ShowRowTotals="False" ShowRowHeaders="False" ShowColumnTotals="False" ShowRowGrandTotals="False" />
<StylesPrint TotalCell-BackColor="Red" />
<Groups>
<dxwpg:PivotGridWebGroup />
</Groups>
<OptionsPager RowsPerPage="50">
</OptionsPager>
</dxwpg:ASPxPivotGrid>
</td>
</tr>
</table>
</div>css

 

 

 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.XtraPivotGrid.Localization;
using System.Collections.Generic;
using DevExpress.Web.ASPxPivotGrid;
using DevExpress.XtraPivotGrid;
public partial class allperson : System.Web.UI.Page
{
ArrayList order = new ArrayList(new object[] { "一大隊", "二大隊", "三大隊", "四大隊", "五大隊", "六大隊", "七大隊", "出入監大隊", "" });
ArrayList order1 = new ArrayList(new object[] { "一大隊一中隊", "一大隊二中隊", "一大隊三中隊", "二大隊一中隊", "二大隊二中隊", "二大隊三中隊", "三大隊一中隊", "三大隊二中隊", "三大隊三中隊", "四大隊一中隊", "四大隊二中隊", "四大隊三中隊", "五大隊一中隊", "五大隊二中隊", "五大隊三中隊", "六大隊一中隊", "六大隊二中隊", "六大隊三中隊", "七大隊總倉", "七大隊後勤隊", "入監隊", "集訓隊", "迴歸中心", "醫院" });
static allperson()
{
MyPivotGridLocalizer.Active = new MyPivotGridLocalizer();ide


}this


protected void Page_Load(object sender, EventArgs e)
{
spa

}server

protected void ASPxPivotGrid1_CustomFieldSort(object sender, PivotGridCustomFieldSortEventArgs e)
{ci

if (e.Field.FieldName == "dname")
{
if (Equals(e.Value1, e.Value2))
{string

e.Result = 0;
}
else
{
e.Result = (order.IndexOf(e.Value1) > order.IndexOf(e.Value2)) ? 1 : -1;
}
}
else if (e.Field.FieldName == "sname")
{it

if (Equals(e.Value1, e.Value2))
{io

e.Result = 0;
}
else
{
e.Result = (order1.IndexOf(e.Value1) > order1.IndexOf(e.Value2)) ? 1 : -1;
}
}
else
return;table


e.Handled = true;

}

protected void ASPxPivotGrid1_CustomSummary(object sender, PivotGridCustomSummaryEventArgs e)
{
if (e.FieldName == "pnum1")
{

this.Label1.Text=e.SummaryValue.CustomValue.ToString();

 

}

}
}

public class MyPivotGridLocalizer : PivotGridLocalizer
{
public override string GetLocalizedString(DevExpress.XtraPivotGrid.Localization.PivotGridStringId id)
{
switch (id)
{
case PivotGridStringId.GrandTotal:

return "<div style="font-weight:bold; color:#003399; font-size:16px" mce_style="font-weight:bold; color:#003399; font-size:16px">合           計 </div>"; } return base.GetLocalizedString(id); }}

相關文章
相關標籤/搜索