Hello Antoine,
According to the provided information, I can suggest you to create a custom summary item that inherits from the GridViewSummaryItem class. You can override its Evaluate method and introduce your custom logic there. Please refer to the following example:
public RadForm1()
{
InitializeComponent();
CustomSummaryItem summaryItem = new CustomSummaryItem();
summaryItem.Name = "HourlySalary";
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
summaryRowItem.Add(summaryItem);
this.radGridView1.SummaryRowsTop.Add(summaryRowItem);
}
publicclassCustomSummaryItem : GridViewSummaryItem
{
public CustomSummaryItem()
{
}
public CustomSummaryItem(string name, string formatString, GridAggregateFunction aggregate)
: base(name, formatString, aggregate)
{ }
public override object Evaluate(IHierarchicalRow row)
{
decimal sum = 0;
foreach (GridViewRowInfo childRow in row.ChildRows)
{
foreach (var column in childRow.ViewTemplate.Columns)
{
if (column is GridViewDecimalColumn)
{
decimal cellValue = Convert.ToDecimal(childRow.Cells[column.Index].Value);
sum += cellValue;
}
}
}
return sum;
}
Note, that in the provided example the summaryItem.Name property is used to specify in which column will be shown the calculated result from the Evaluate method. More information about creating custom GridViewSummaryItem is available here.
This example is a sample demonstration. Feel free to modify it in a way that is most suitable for you.
I hope this helps. Should you have further questions do not hesitate to contact me.
Regards,
Nadya
Progress Telerik
Progress is here for your business, like always.
Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.