Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
445
Formatting Summary Column
posted

I have been trying to format the summary column in the code behind

SumSummaryOperand sum = new SumSummaryOperand();

sum.FormatString = "{0.00}";

col.SummaryColumnSettings.SummaryOperands.Add(sum);

I dont want the summary of the column to appear by default. User should be able to choose to view it depending on his need. But when I click the sigma sign on the column header, I see two 'Sum' options. How do I avoid this issue? I want Sum or Average to have same format as that of the values in the column.

 

 

  • 6475
    Suggested Answer
    posted

    Hi,

    Basically, you're getting two "Sum" options because you add a second Sum operand to your operands collection.

    So if you want to set the FormatString from code behind you'll need to:

    a) Remove the auto-generated "Sum" operand before adding your newly created one

    b) Apply the format string on the auto-generated "Sum" operand that's already there

    The following snippet applies a format string on all "Sum" and "Average" operands of all top-level columns of the grid:

            private void SetFormatStringOnSummaryOperands()
            {
                var operandsList = from columms in igGrid.Columns.DataColumns
                                   from operands in columms.SummaryColumnSettings.SummaryOperands
                                   where ((operands is SumSummaryOperand) || (operands is AverageSummaryOperand))
                                   select operands;
    
                foreach (SummaryOperandBase operand in operandsList)
                {
                    operand.FormatString = "{0:0.00}";
                }                                
            }
    

     

    Hope this helps,