Gird And Excel Export

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.





10 Replies

NG Nagendra Gupta August 26, 2022 10:27 AM UTC

Please find the attach file.


Attachment: excelimage_f81fbeed.zip


NG Nagendra Gupta replied to Nagendra Gupta August 31, 2022 04:48 AM UTC

Dear Team,

I am waiting for your reply.



JC Joseph Christ Nithin Issack Syncfusion Team August 31, 2022 07:06 PM UTC

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.



NG Nagendra Gupta replied to Joseph Christ Nithin Issack September 2, 2022 07:36 AM UTC

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.




JC Joseph Christ Nithin Issack Syncfusion Team September 5, 2022 07:05 PM UTC

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.



NG Nagendra Gupta September 6, 2022 05:40 AM UTC

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



VB Vinitha Balasubramanian Syncfusion Team September 12, 2022 05:57 PM UTC

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



NG Nagendra Gupta September 20, 2022 07:19 AM UTC

Hi Vinitha,


Is there any update on this?


Regards,

Nagendra



JC Joseph Christ Nithin Issack Syncfusion Team September 22, 2022 04:12 PM UTC

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



JC Joseph Christ Nithin Issack Syncfusion Team September 28, 2022 06:00 PM UTC

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 (gobjpropsr) {

        var rows = processGridExportObject.call(thisgobjpropsr);

        rows.forEach((itemindex=> {

          if (item.cells.length == 1) {

            rows.splice(index1);

          }

        });

        rows.forEach((itemindex=> {

          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.



Loader.
Up arrow icon