We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Custom Aggregate doesn't work

The example on documentation about customAggregate doesn't work.

The property customAggregate looking for a c# object not a javascript function, and if I create a C# function like this



object Foo()
{
     return 0;
}

the result is not displayed.


<ejs-grid id="Grid" dataSource=@ViewBag.DataSource allowPaging="true">
   
<e-grid-aggregates>
       
<e-grid-aggregate>
           
<e-aggregate-columns>
               
<e-aggregate-column field="ShipCountry"  type="Custom" footerTemplate="Brazil Count:${Custom}" customAggregate="customAggregateFn">e-aggregate-column>
           
e-aggregate-columns>
       
e-grid-aggregate>
   
e-grid-aggregates>
   
<e-grid-pagesettings pageCount="5">e-grid-pagesettings>
   
<e-grid-columns> <e-grid-column field="CustomerID" headerText="Customer Name" width="150">e-grid-column>
       
<e-grid-column field="Freight" headerText="Freight" textAlign="Right" format="C2" width="160">e-grid-column>
       
<e-grid-column field="OrderDate" headerText="Order Date" format="yMd" textAlign="Right" width="130">e-grid-column>              
       
<e-grid-column field="ShipCountry"  headerText="Ship Country" width="140">e-grid-column>               
   
e-grid-columns>
ejs-grid>

<script>
function customAggregateFn (data) {

    return data.result.filter(function (item) {
        return item['ShipCountry'] === 'Brazil';
    }).length;
}
>


Is possible to completely customize the groupFooter and/or the captionFooter has a single line like this:

Customer: 100, Budget: € 15.000,00 - AmountTotal € 18.000  

Thanks


1 Reply

DR Dhivya Rajendran Syncfusion Team March 20, 2018 01:18 PM UTC

Hi Massimo, 
Thanks for contacting Syncfusion support, 
We have validated your query and prepare a sample for your reference, In this below sample we have used load event to assign the value for the customAggregate properties, kindly please refer the below sample and code snippet for more information, 

index.cshtml: 
    <ejs-grid id="Grid" dataSource="ViewBag.datasource" load="load " allowPaging="true" allowSorting="true" allowFiltering="true"> 
        <e-grid-aggregates> 
                   . . . . . 
                    <e-aggregate-column field="ShipCountry" type="Custom" footerTemplate="Brazil Count:${Custom}"></e-aggregate-column> 
        <e-grid-columns> 
         . . . . 
        </e-grid-columns> 
    </ejs-grid> 
<script> 
    function load() { 
        this.aggregates[0].columns[0].setPropertiesSilent({ customAggregate: customAggregateFn });                  
    } 
    function customAggregateFn(data) { 
      return data.result.filter(function (item) { 
           return item['ShipCountry'] === 'Brazil'; 
    }).length; 
} 
</script> 


Query2: Is possible to completely customize the groupFooter and/or the captionFooter has a single line ? 
 
Yes, it’s possible, we have analyzed your requirement and create a sample for your reference, please refer the below sample and documentation link for more information, 
 
 
 
 
Regards,
R.Dhivya
 


Loader.
Live Chat Icon For mobile
Up arrow icon