关于合计行的问题
因为客户要求,需要在第一行添加合计行,并且不受到排序的影响始终在第一行,所以用了 <c1:C1DataGrid.TopRows> <c1:DataGridSummaryRow /></c1:C1DataGrid.TopRows>
但是因为有2列是通过其他2各字段进行了除法计算 算的是比例 所以累加就不对了 需要如何处理呢?
如图
根据您提供的信息,不能重现您的问题。
建议您参考下我们的随机安装示例:
\Documents\ComponentOne Samples\WPF\C1.WPF.DataGrid\CS\DataGridSamples\Grouping\GrandTotal 这是我现在前台所用的代码,金额人次都是累加计算,但是占比的话 需要通过其中两列进行合计计算后进行除法,同时第一列的合计行不会应为排序改变移动位置 是否可以给我一个示例
<c1datagrid:C1DataGrid x:Name="dgList" Grid.Row="1" Style="{StaticResource C1DataGrid}"SelectionMode="SingleCell" >
<c1datagrid:C1DataGrid.Columns>
<c1datagrid:DataGridTextColumn Header="规则名称" Binding="{Binding RULE_NAME}" CellStyle="{StaticResource C1DataGridCellPresenterStyle}" SortMemberPath="RULE_NAME" Format="合计">
<c1:DataGridAggregate.AggregateFunctions>
<c1:DataGridAggregatesCollection>
<c1:DataGridAggregateSum ></c1:DataGridAggregateSum>
</c1:DataGridAggregatesCollection>
</c1:DataGridAggregate.AggregateFunctions>
</c1datagrid:DataGridTextColumn>
<c1datagrid:DataGridNumericColumn Header="违规次数" Binding="{Binding EXP_ORD_COUNT}" SortMemberPath="EXP_ORD_COUNT" Format="0">
<c1:DataGridAggregate.AggregateFunctions>
<c1:DataGridAggregatesCollection>
<c1:DataGridAggregateSum ></c1:DataGridAggregateSum>
</c1:DataGridAggregatesCollection>
</c1:DataGridAggregate.AggregateFunctions>
</c1datagrid:DataGridNumericColumn>
<c1datagrid:DataGridNumericColumn Header="违规金额(万元)" Binding="{Binding EXP_COSTS}" SortMemberPath="EXP_COSTS" Format="0.0000">
<c1:DataGridAggregate.AggregateFunctions>
<c1:DataGridAggregatesCollection>
<c1:DataGridAggregateSum ></c1:DataGridAggregateSum>
</c1:DataGridAggregatesCollection>
</c1:DataGridAggregate.AggregateFunctions>
</c1datagrid:DataGridNumericColumn>
<!--<c1datagrid:DataGridHyperlinkColumn Header="违规医院(个)" Binding="{Binding EXP_HOS_COUNT}" Click="DataGridHyperlinkColumnYY_Click" SortMemberPath="ORD_PHYSICIAN" Format="0.00">
<c1:DataGridHyperlinkColumn.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding EXP_HOS_COUNT}"></TextBlock>
</DataTemplate>
</c1:DataGridHyperlinkColumn.ContentTemplate>
</c1datagrid:DataGridHyperlinkColumn>-->
<c1datagrid:DataGridNumericColumn Header="违规医院(个)" Binding="{Binding EXP_HOS_COUNT}" CellStyle="{StaticResource C1DataGridCellPresenterStyle}" SortMemberPath="EXP_HOS_COUNT" Format="0">
<c1:DataGridAggregate.AggregateFunctions>
<c1:DataGridAggregatesCollection>
<c1:DataGridAggregateSum ></c1:DataGridAggregateSum>
</c1:DataGridAggregatesCollection>
</c1:DataGridAggregate.AggregateFunctions>
</c1datagrid:DataGridNumericColumn>
<!--<c1datagrid:DataGridHyperlinkColumn Header="涉及科室(个)" Binding="{Binding ORD_DEPT}" Click="DataGridHyperlinkColumnKS_Click" SortMemberPath="ORD_PHYSICIAN" Format="0.00">
<c1:DataGridHyperlinkColumn.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding ORD_DEPT}"></TextBlock>
</DataTemplate>
</c1:DataGridHyperlinkColumn.ContentTemplate>
</c1datagrid:DataGridHyperlinkColumn>-->
<c1datagrid:DataGridNumericColumn Header="涉及科室(个)" Binding="{Binding ORD_DEPT}" CellStyle="{StaticResource C1DataGridCellPresenterStyle}" SortMemberPath="ORD_DEPT" Format="0">
<c1:DataGridAggregate.AggregateFunctions>
<c1:DataGridAggregatesCollection>
<c1:DataGridAggregateSum ></c1:DataGridAggregateSum>
</c1:DataGridAggregatesCollection>
</c1:DataGridAggregate.AggregateFunctions>
</c1datagrid:DataGridNumericColumn>
<!--<c1datagrid:DataGridHyperlinkColumn Header="涉及医生(人)" Binding="{Binding ORD_PHYSICIAN}" Click="DataGridHyperlinkColumnYS_Click" SortMemberPath="ORD_PHYSICIAN" Format="0.00">
<c1:DataGridHyperlinkColumn.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding ORD_PHYSICIAN}"></TextBlock>
</DataTemplate>
</c1:DataGridHyperlinkColumn.ContentTemplate>
</c1datagrid:DataGridHyperlinkColumn>-->
<c1datagrid:DataGridNumericColumn Header="涉及医生(个)" Binding="{Binding ORD_PHYSICIAN}" CellStyle="{StaticResource C1DataGridCellPresenterStyle}" SortMemberPath="ORD_PHYSICIAN" Format="0">
<c1:DataGridAggregate.AggregateFunctions>
<c1:DataGridAggregatesCollection>
<c1:DataGridAggregateSum ></c1:DataGridAggregateSum>
</c1:DataGridAggregatesCollection>
</c1:DataGridAggregate.AggregateFunctions>
</c1datagrid:DataGridNumericColumn>
<c1:DataGridHyperlinkColumn Header=""FilterMemberPath="BillDetail" Click="DataGridHyperlinkColumnDJ_Click">
<c1:DataGridHyperlinkColumn.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding BillDetail}"></TextBlock>
</DataTemplate>
</c1:DataGridHyperlinkColumn.ContentTemplate>
</c1:DataGridHyperlinkColumn>
</c1datagrid:C1DataGrid.Columns>
<c1datagrid:C1RowIndexHeaderBehavior.RowIndexHeaderBehavior>
<c1:C1RowIndexHeaderBehavior InitialIndex="1" />
</c1datagrid:C1RowIndexHeaderBehavior.RowIndexHeaderBehavior>
<c1:C1DataGrid.TopRows>
<c1:DataGridSummaryRow />
</c1:C1DataGrid.TopRows>
</c1datagrid:C1DataGrid> jim_hujun 发表于 2016-5-24 15:02
这是我现在前台所用的代码,金额人次都是累加计算,但是占比的话 需要通过其中两列进行合计计算后进行除法 ...
谢谢您提供的代码,使用DataGridSummaryRow进行分组。
除了默认的计算,如果您需要自定义分组里的信息,可以重写GroupConverter。
然后在里面重写自己的计算逻辑。
请参考产品文档:
http://blog.gcpowertools.com.cn/post/2015/12/17/C1DataGridWPF_CustomGroup.aspx
页:
[1]