Skip to content

Infragistics Community Forum / Web / Ignite UI for Angular / when selected check boxes rows should export to excel only those selected

when selected check boxes rows should export to excel only those selected

New Discussion
Ameur Mezaache
Ameur Mezaache asked on Feb 12, 2020 9:17 AM

I’m using IGX-GRID that has check boxes and want click export to excel want to show on excel only the selected ones.

Any help implementing this feature will be appreciate it.

Sign In to post a reply

Replies

  • 0
    Martin Asenov
    Martin Asenov answered on Dec 18, 2019 12:57 PM

    Hello Ameur,

    Thank you for posting in our community.

    You can achieve the required by getting the selected rows using selectedRows method of the igxGrid and then passing the data to the IgxExcelExporterService's exportData method:

    public exportButtonHandler() {   
        this.excelExportService.exportData(this.grid.selectedRows(), new IgxExcelExporterOptions("ExportFileFromGrid"));
     }

    I have created sample for your reference.

    • 0
      Ameur Mezaache
      Ameur Mezaache answered on Dec 18, 2019 6:33 PM

      Thanks a lot it did work for me, however if I don't select any thing and hit export it firing and empty excel.

      Any way to not display it in case no selection made?

      Thanks

    • 0
      Ameur Mezaache
      Ameur Mezaache answered on Dec 18, 2019 7:01 PM

      Maybe enable export button only when rows selected how this will be achieved please

      • 0
        Martin Asenov
        Martin Asenov answered on Dec 19, 2019 11:11 AM
        Hello Ameur,
         
        My suggestion is to use a conditional statement to check if there is a selected row:

        public exportButtonHandler() {
        	if (this.grid.selectedRows().length > 0) {
        		this.excelExportService.exportData(this.grid.selectedRows(), new IgxExcelExporterOptions("ExportFileFromGrid"));
        	} else {
        		this.excelExportService.export(this.grid, new IgxExcelExporterOptions("ExportFileFromGrid"));
        	} 
        }
         
        I have updated the sample for your reference.
      • 0
        Shankargouda Goudati
        Shankargouda Goudati answered on Feb 10, 2020 3:14 PM

        What if we want to export selective columns and not all columns in grid? Please assist on this. 

      • 0
        Martin Asenov
        Martin Asenov answered on Feb 12, 2020 9:17 AM

        Hi Shankargouda,

        You can subscribe to the onColumnExport event emitted by the excelExportService and conditionally choose which columns should be exported:

        public ngAfterViewInit() {
            this.excelExportService.onColumnExport.subscribe( column => {
                if (column.field == "Name") column.cancel = true;
            })
        }

        Please keep in mind that this thread is about exporting selected rows and nevertheless that its relative to excel exporting, my suggestion is to create a new thread in our forum for your specific query. This way we can address your issues more accurately.

        Thank you for using Infragistics components.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Ameur Mezaache
Favorites
0
Replies
6
Created On
Feb 12, 2020
Last Post
6 years ago

Suggested Discussions

Tags

Created by

Created on

Feb 12, 2020 9:17 AM

Last activity on

Feb 11, 2026 4:24 PM