Summary issue, it dont count

Hi!

I tried to add a summary to my grid but doesn´t work. I tried a summary with numbers and false/true count and neither works.

Did I forget something to make it work?



This is my View:



And datasource:



Thanks, regards!

5 Replies

VN Vignesh Natarajan Syncfusion Team October 26, 2017 02:38 PM UTC

Hi Daniel, 

Thanks for using Syncfusion products. 

We have analyzed your query and we are able to reproduce the reported issue. While using remote data Summary Row must be handled in the server side by returning the summary column dataSource into the aggregates property of result object.  

Please refer the below code snippet (server side) 

if (dm.Aggregates != null) 
            { 
                for (var i = 0; i < dm.Aggregates.Count; i++) 
                    str.Add(dm.Aggregates[i].Field); 
 
            } 
            IEnumerable aggregate = ds.PerformSelect(DataSource, str); 
            var count = order.Count(); 
            DataSource = ds.PerformSkip(DataSource, dm.Skip); 
            DataSource = ds.PerformTake(DataSource, dm.Take); 
            return Json(new { result = DataSource, count = count, aggregate = aggregate }); 

Refer the below code snippet for the output 

 

For your convenience we have prepared a sample which can be downloaded from below link 

Refer our online documentation for your reference 


Regards, 
Vignesh Natarajan 



DA Daniel October 26, 2017 05:09 PM UTC

Perfect! It works, that was the missing thing. Another question related to summary... is it possible to add a new line that summatize all totals?




Thanks, regards!


VN Vignesh Natarajan Syncfusion Team October 27, 2017 04:30 PM UTC

Hi Daniel, 
 
Thanks for the update. 
 
Query: “is it possible to add a new line that summatize all totals?” 
 
We have analyzed your query and we have achieved your requirement through the Custom summary feature of the Grid. Please the below code snippet. 
 
                   . 
                   . 
                   . 
.SummaryRow(row => 
                   { 
                       row.Title("Total").SummaryColumns(col => { col.SummaryType(SummaryType.Sum).DisplayColumn("Freight").DataMember("Freight").Add(); col.SummaryType(SummaryType.Sum).DisplayColumn("Number").DataMember("Number").Add(); }).Add(); 
                       row.Title("Full Total").SummaryColumns(col => { col.SummaryType(SummaryType.Custom).CustomSummaryValue("Total").DisplayColumn("Freight").Add(); }).Add(); 
                   })  
             .  
             . 
             . 
<script type="text/javascript"> 
     function Total() { 
         return this._remoteSummaryData["Freight - sum"] + this._remoteSummaryData["Number - sum"]; 
  } 
    </script> 
 
Refer the below code snippet for output 
 
 
 
For your convenience we have prepared a sample which can be downloaded from below link 
 
 
Refer our help documentation for your reference 
 
 
Regards, 
Vignesh Natarajan 
 
 



DA Daniel October 27, 2017 06:32 PM UTC

Perfect!

Works fine, thanks for your help.

Regards!


VN Vignesh Natarajan Syncfusion Team October 30, 2017 12:48 PM UTC

Hi Daniel, 

Thanks for the update. 

We are glad that your query has been resolved by our solution. 

Please get back to us, if you need any assistance in future. 

Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon