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
770
Summarize with criteria?
posted

Hi guys.

I have a grid and at the bottom there is a sum of 1 column.

Is there any way that I can do to ignore some rows?

For example, I want to ignore the row that with 'Waste' text.

Parents
  • 71886
    Suggested Answer
    Offline posted

    Hello engloon,

    If I got you right I believe that you could try out the following code sample and see if it meets your requirements:

            public class SummaryCalculator : ICustomSummaryCalculator
            {
                private double total = 0;
                double notNeeded;
                public void AggregateCustomSummary(SummarySettings settings, UltraGridRow row)
                {
                    notNeeded = 0;
                    if (row.Cells["Column 1"].Text == "Waste")
                    {
                        notNeeded += Convert.ToInt16(row.Cells["Column 0"].Value);
                    }
                    else total += Convert.ToInt16(row.Cells["Column 0"].Value);
    
                    Console.WriteLine("NotNeed: " + notNeeded.ToString() + " Total: " + Convert.ToInt16(row.Cells["Column 0"].Value));
                }
    
                public void BeginCustomSummary(SummarySettings settings, RowsCollection rows)
                {
                    this.total = 0;
                }
    
                public object EndCustomSummary(SummarySettings settings, RowsCollection rows)
                {
                    return this.total - notNeeded;
                }
    
            }
    

     

    Please feel free to let me know if I misunderstood you or if you have any other questions.

Reply Children
No Data