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

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


    }


    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void ASPxPivotGrid1_CustomFieldSort(object sender, PivotGridCustomFieldSortEventArgs e)
    {

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

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

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

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


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

  • 相关阅读:
    练习上传下载时遇到的问题
    el表达式遇到的问题
    js中for循环闭包问题记录
    随机排座位(模板) 20.10.17
    #STL:优先队列数据结构函数的用法 #堆 #优先队列数据结构(堆) #priority_queue 20.10.17
    关于int的范围
    #归并排序 归并排序的刷题记录 ~20.09.25
    #欧拉函数 ~20.8.27
    #排列 #组合 ~20.8.24
    105.七夕祭
  • 原文地址:https://www.cnblogs.com/lyl6796910/p/4045119.html
Copyright © 2020-2023  润新知