Hi,
I have a datagrid featuring a simple calculated column, the expression being
@{
decimal pallets = 0;
if (consignmentlots.CLCasesPerPallet == 0 || consignmentlots.CLQty == 0) { pallets = 0; } else { pallets = consignmentlots.CLQty / consignmentlots.CLCasesPerPallet; };
}
This works fine, but is there a way to show to sum of this column in a Footer Template?
Many thanks
Reg
Yes, you can use a sum over your data to create the footer total:
@(data.Sum(consignmentlots =>
{
decimal pallets = 0;
if (consignmentlots.CLCasesPerPallet == 0 || consignmentlots.CLQty == 0)
{
pallets = 0;
} else {
pallets = consignmentlots.CLQty / consignmentlots.CLCasesPerPallet;
}
return pallets;
});
That's cool, thanks korchev
Sorry, one more question on this. If I have another calculated column whose value is derived from a c# function, can I use the construct you've shown here to get a total for that column as well?
Here's the clause from the applicable Numeric column type:
Change="(decimal x) => OnChangeLineValue(consignmentlots.CLSizeId,consignmentlots.CLQty,consignmentlots.CLPrice,consignmentlots.CLPriceUnit)"
Thanks again
Reg