计算动态加载行后的部分字段的计算求和操作
表格上添加事件触发ItemsSourceChanged属性,触发事件
<c1:C1FlexGrid Name="CfgSaleOrderReviewItem" Style="{StaticResource Green}" ItemsSource="{Binding SaleOrderList,Mode=TwoWay}" SelectedItem="{Binding CurrentSaleOrderItem,Mode=TwoWay}"
LoadedRows="FlexGrid_LoadedSaleOrderRows_RowIndex" PreviewKeyDown="c1FlexGrid_PreviewKeyDown" IsReadOnly="False"
ItemsSourceChanged="DetailGrid_ItemsSourceChanged">
编写事件
/// <summary>
/// 列表1合计
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DetailGrid_ItemsSourceChanged(object sender, EventArgs e)
{
var vm = DataContext as PlateReplaceApplyFormVM;
if (vm == null) return;
CfgSaleOrderReviewItem.ColumnFooterRows.Clear();
var gr = new GroupRow()
{
FontWeight = FontWeights.Bold
};
if (vm.SaleOrderList != null && vm.SaleOrderList.Count > 0) {
CfgSaleOrderReviewItem.ColumnFooters.Rows.Add(gr);
gr["ManagerName"] = "合计";
gr["ProductQuantity"] = vm.SaleOrderList == null ? 0 : vm.SaleOrderList.Sum(p => Convert.ToInt32(p.ProductQuantity));
gr["ProductTotalArea"] = vm.SaleOrderList == null ? 0 : vm.SaleOrderList.Sum(p => Convert.ToDouble(p.ProductTotalArea));
}
}
效果