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

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

private void gvTop_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e)
{
  if (e.IsTotalSummary && e.SummaryProcess == CustomSummaryProcess.Finalize)
  {
    // 数据源
    var data = this.gcTop.DataSource as List<StockOrderDetail_V>;

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

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

  }
}

posted @ 2017-07-15 11:11  惊梦无痕  阅读(1620)  评论(0编辑  收藏  举报