- Home
- Forum
- ASP.NET Core - EJ 2
- Custom Aggregate doesn't work
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;
}
>
<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
>
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
SIGN IN To post a reply.
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,
|
|
Documentation: https://ej2.syncfusion.com/16.1.24/aspnet/documentation/grid/aggregates.html?syntax=tag
Regards,
R.Dhivya
R.Dhivya
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
MG Massimo Giambona
- Mar 19, 2018 03:01 PM UTC
- Mar 20, 2018 01:18 PM UTC