GroupSummaryRow SUM

Hi 

I am trying to Display a Summary Field on a Group Caption.

The Data Source is a Data Table;

When I Group on a Field (Cattle) and then total the values and display;

the values sent to the datatable are INT but i have tried string also,

I have also tried various string formats but am unsure ?

When i swicth to a count it works and displays the number of rows in each group.

I think i am missing something simple 

----------------------------------------------------------------
//Created Data Table 
            DataTable dt = new DataTable();
            dt.Columns.Add("Cattle");
            dt.Columns.Add("Name");
            dt.Columns.Add("CountAnimals");

            DataRow r = dt.NewRow();
            r["Cattle"] = "1.Cows (Dairy & Suckler)";
            r["Name"] = "Dairy Cows";
            r["CountAnimals"] = dairyc; //INT
            dt.Rows.Add(r);

            r = dt.NewRow();
            r["Cattle"] = "1.Cows (Dairy & Suckler)";
            r["Name"] = "Suckler Cows";
            r["CountAnimals"] = sucklerC; //INT
            dt.Rows.Add(r);

            r = dt.NewRow();
            r["Cattle"] = "6.Other";
            r["Name"] = "Breeding Bulls";
            r["CountAnimals"] = breedingBull; //INT
            dt.Rows.Add(r);
----------------------------------------------------------------------------------------

//grouping

            StockInfoView.DataSource = GetStockInfoDataTable(DateTime.Now);
            StockInfoView.GroupColumnDescriptions.Add(new GroupColumnDescription() { ColumnName = "Cattle" });
            StockInfoView.Columns[0].Visible = false;         
            StockInfoView.CaptionSummaryRow = new GridSummaryRow()
            {
                Name = "CaptionSummary",
                ShowSummaryInRow = true,
                Title = "{Key} : {CaptionSummaryColumn}",
                SummaryColumns = new ObservableCollection<ISummaryColumn>()
                {
                    new GridSummaryColumn()
                    {
                        MappingName = "CountAnimals",
                        Format="{Sum:c}",                               //have tried {Sum:d} {Sum} 
                        SummaryType= SummaryType.DoubleAggregate, //have tried INT 
                        Name = "CaptionSummaryColumn",
                    }
                },
            };
---------------------------------------------------------------------------------------------------------------------------------
What am I doing wrong ? 

Peter ?

3 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team May 24, 2021 03:43 PM UTC

Hi Peter,

Thank you for contacting Syncfusion Support.

Based on provided information we have checked your provided code snippet. We suspect that your requirement sums the string value in Summary. If yes, cannot sum the string value in Summaries.

We have prepared the simple sample based on provided code snippet,

Sample Link: https://www.syncfusion.com/downloads/support/forum/165683/ze/Sample-1946970807

Screenshot for your reference,


If we misunderstood your requirement, please provide more information with image illustration of your requirement. This would help us to proceed further.

Regards,
Vijayarasan S
 


Marked as answer

PE Peter May 24, 2021 04:04 PM UTC

Hi Vijayarasan S

Your Sample has solved my issue. 

  DataTable dt = new DataTable();
            dt.Columns.Add("Cattle");
            dt.Columns.Add("Name");           
     
           dt.Columns.Add("CountAnimals");   // 
by changing this to dt.Columns.Add("CountAnimals",typeof(double));

Thank you 

Peter 


MA Mohanram Anbukkarasu Syncfusion Team May 25, 2021 06:37 AM UTC

Hi Peter, 

Thanks for the update.  

We are glad to know that the provided solution resolved the problem in your end. Please let us know if you require any other assistance from us.  

Regards, 
Mohanram A. 


Loader.
Up arrow icon