Dear Team,
We want
conditional GroupCaptionTemplate and GroupFooterTemplate at the time of grouping in ejs-grid and as well as exporting of excel also.
It means row Party Name: A TO Z PVT. LTD. - 1 item and Party Name: Demo PVT. LTD.- 1 item should be conditional.
I have attached the excel image for example.
Dear Team,
I am waiting for your reply.
Hi Nagendra,
Sorry for the late reply.
Based on your requirement, you want to customize the aggregate value when you generate aggregate columns in typescript way. You can achieve your requirement by using customHelper function inside the template. The customized value will be shown in the Grid and the same will be exported in the pdf and excel files too. Find the below code example and sample for more information.
customHelper: https://ej2.syncfusion.com/documentation/common/template-engine/#custom-helper
|
[app.component.ts]
export class AppComponent { ----
public ngOnInit(): void { --- this.aggregates = [ { columns: [ { type: 'Sum', field: 'UnitsInStock', groupFooterTemplate: 'Total units: ${customHelper(Sum)}' // use customHelper function to customize the aggregate value }, { type: 'TrueCount', field: 'Discontinued', groupFooterTemplate: 'Discontinued: ${TrueCount}' }, { type: 'Max', field: 'UnitsInStock', groupCaptionTemplate: 'Maximum: ${customHelper(Max)}' // use customHelper function to customize the aggregate value } ] } ]; } }
(window as any).customHelper = function(num) { const amount = Number(num).toFixed(2); return Number(amount).toLocaleString('de'); // customize the value as you want };
|
Sample: https://stackblitz.com/edit/angular-zxqbdq-shcqak?file=app.component.ts
Please get back to us if you need further assistance with this.
Regards,
Joseph I.
Hi Joseph Christ Nithin Issack ,
Thanks for your reply.
As per your reply our requirement is not full filling. In your example there are two group rows.
1. Category Name: Beverages - 11 items
2. Category Name: Condiments - 1 item
Actually at time of excel export we do not want to export this rows and also not show in grid.
Hi Nagendra,
Thanks for your update.
Based on the provided information, you don’t want to display the group caption in the grid and while exporting. In the below documentation we have discussed in detail on customizing the group caption template in the grid. And you can also customize the group caption while exporting using the `exportGroupCaption` event of the EJ2 Grid.
Documentation: https://ej2.syncfusion.com/angular/documentation/grid/grouping/caption-template/
https://ej2.syncfusion.com/angular/documentation/api/grid/#exportgroupcaption
Sample: https://stackblitz.com/edit/angular-zxqbdq-k5msyp?file=app.component.ts,app.component.html
Please refer the sample and documentation and get back to us for further details.
Regards,
Joseph I.
Hi Joseph Christ Nithin Issack ,
Thanks for your reply.
As per your previous reply our requirement is 90% fullfill. 10% of requirement is not full fill yet that is when we exporting grid into excel blank row of GroupCaptionTemplate is export.
Our requirement is not exporting blank row of GroupCaptionTemplate at the time of export.
Regards,
Nagendra
Hi Nagendra,
Thanks for your update.
We have currently validating your query based on your shared information, we will update the further details on or before Sep 14th, 2022. Until then we appreciate your patience.
Regards,
Vinitha Balasubramanian
Hi Vinitha,
Is there any update on this?
Regards,
Nagendra
Hi Nagendra,
Thanks for your update.
We are still checking the feasibility of your requirement, we need some more time for validation. We will provide further details on or before 26th September, 2022 . Until then we appreciate your patience.
Regards,
Joseph I
Hi Nagendra,
Sorry for the inconvenience caused.
As per your request, we have removed the blank
group caption template row while exporting.
We have removed the blank line using the
private method in the created event of the EJ2 Grid.
Please refer the below code example.
|
created() { var processGridExportObject = (this.grid.excelExportModule as any).__proto__ .processGridExport; (this.grid.excelExportModule as any).__proto__.processGridExport = function (gobj, props, r) { var rows = processGridExportObject.call(this, gobj, props, r); rows.forEach((item, index) => { if (item.cells.length == 1) { rows.splice(index, 1); } }); rows.forEach((item, index) => { item.index = index + 1; }); return rows; }; }
|
Sample: https://stackblitz.com/edit/angular-zxqbdq-e7oxz6?file=app.component.ts,app.component.html
Please get back to us for further details.
Regards,
Joseph I.