zoukankan      html  css  js  c++  java
  • PivotGridField 中对Unbound的列赋值(除法)

     此方法也可以同时对CustomSummaryCalculate的百分比计算有效

    .aspx中<Fields>内的代码:

    <dx:PivotGridField ID="field_corr" Area="DataArea" AreaIndex="0"  FieldName="诊断符合数" ValueFormat-FormatType="Numeric" Caption="诊断符合数"> </dx:PivotGridField>
    <dx:PivotGridField ID="field_Sum" Area="DataArea" AreaIndex="1"  FieldName="诊断总数"  Caption="诊断总数"></dx:PivotGridField>
    <dx:PivotGridField ID="field_compare" Area="DataArea" AreaIndex="2"   FieldName=""   UnboundType="Decimal"  Caption="诊断符合率" SummaryType="Custom">  </dx:PivotGridField>

    其中诊断符合率=诊断符合数/诊断总数

    但是在用Unbound的前台表达式中绑定字段除法后得到的结果为0(加减乘均可以直接在前台表达式UnboundExpression中赋值)

    除法需要在后台绑定OnCustomCellDisplayText事件:OnCustomCellDisplayText="pivotGrid_CustomCellDisplayText"

    .cs

    protected void pivotGrid_CustomCellDisplayText(object sender, PivotCellDisplayTextEventArgs e)          {             

        if (object.ReferenceEquals(e.DataField, ASPxPGDiagnosticAccordanceRate.Fields["诊断符合率"]))  { //判断传的参数所在的列(每列均传递一次)

          PivotGridField corrcount = ASPxPGDiagnosticAccordanceRate.Fields["诊断符合数"];

          object Corrcount = e.GetCellValue(corrcount);

                     PivotGridField sumcount = ASPxPGDiagnosticAccordanceRate.Fields["诊断总数"];

                     object Sumcount = e.GetCellValue(sumcount);                 

          if (Sumcount == null) return;

                     decimal perc = (decimal)Corrcount / (decimal)Sumcount;//计算结果

                     e.DisplayText = string.Format("{0:p}", perc);//显示为百分数的形式

                 }         

    }

  • 相关阅读:
    通过pwndbg看看c中局部变量是如何在stack上放置的 此外 printf %n的作用终于弄明白了
    pip 安装过慢 使用清华源 加速
    mac 10.15.6 安装 IDA
    使用机器学习检测命令行混淆
    安全技能树简版
    栈溢出 hack 入门例子 hello world
    201116西瓜书机器学习系列---8、集成学习
    legend2---某些js代码电脑浏览器支持,手机浏览器不支持的调试
    legend2---做题页的每个题目对应的答案重点标颜色
    legend2---jquery重新渲染某元素
  • 原文地址:https://www.cnblogs.com/shirley-w/p/4042391.html
Copyright © 2011-2022 走看看