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