首页 > 代码库 > DevExpress中GridControl自定义汇总列值(有选择性的汇总)

DevExpress中GridControl自定义汇总列值(有选择性的汇总)

今天碰到有同事遇到这个方面的需求,贴一下吧。

private void gvTop_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e)
{
  if (e.IsTotalSummary && e.SummaryProcess == CustomSummaryProcess.Finalize)
  {
    // 数据源
    var data = http://www.mamicode.com/this.gcTop.DataSource as List;

    // 统计项
    var item = e.Item as GridColumnSummaryItem;

    switch (item.FieldName)
    {
      case "FACTAMT":
        data = http://www.mamicode.com/data.FindAll(x => x.IsChecked == 1);
        e.TotalValue = http://www.mamicode.com/data.Sum(x => x.FACTAMT);
        break;
      default:
        break;
    }

  }
}

DevExpress中GridControl自定义汇总列值(有选择性的汇总)