beforeExcelExport, beforePdfExport

Hello,

I want to allow user to export grid only if there are less than, for example, 1000 rows (grid original can have less than 1000 rows or it could be filtered to have less than 1000 rows). I think I should check it in methods beforeExcelExport and beforePdfExport but in these methods like arguments I am getting - undefined. If it should be getting undefined?

Maybe I am thinking wrong and should check it somewhere else? Also how can I prevent from exporting after click on button which executes method excelExport? With grid I am also using paging, grouping, filtering, sorting methods.

1 Reply

MF Mohammed Farook J Syncfusion Team July 18, 2018 09:49 AM UTC

Hi AC, 
 
Thanks for contacting Syncfusion support. 
 
We have validated your query and we are able to reproduce the reported problem.  We have considered as  “Need to pass arguments in beforeExcelExport, beforePdfExport events” as usability feature and it will be available in any of our upcoming release.  But we have achieved your requirement by using toolbarClickEvent. Please find the code example and sample for your reference. 
 
[app.component.html] 
  <ejs-grid #grid [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [toolbar]='toolbar' (toolbarClick)='toolbarClick($event)' 
              [allowExcelExport]='true' [allowPdfExport]='true' [allowGrouping]="true" allowFiltering='true'> 
        <e-columns> 
            <e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right' isPrimaryKey='true'></e-column> 
            . . . 
        </e-columns> 
    </ejs-grid> 
 
[app.component.ts] 
 
    export class AppComponent implements OnInit { 
 
  public data: Object[]; 
  public toolbar: string[]; 
  public pageSettings: Object; 
  @ViewChild('grid') 
  public grid: GridComponent; 
 
 
  ngOnInit(): void { 
    this.data = orderDetails; 
    this.toolbar = ['ExcelExport', 'PdfExport']; 
    this.pageSettings = { pageCount: 5 }; 
  } 
 
  toolbarClick(args: ClickEventArgs): void { 
// export allows when grid has lessthan 10 records 
    if (this.grid.pageSettings.totalRecordsCount < 10) { 
      switch (args.item.text) { 
        case 'PDF Export': 
          this.grid.pdfExport(); 
          break; 
        case 'Excel Export': 
          this.grid.excelExport(); 
          break; 
      } 
    } else { 
      alert('export prevented '); 
    } 
 
  } 
} 
 
 
 
 
Regards, 
J  Mohammed Farook 
 


Loader.
Up arrow icon