My requirement is when i click on ExportExcel button in toolbar i want to call actionBegin() event here i am provie my sample of coe

 
this.toolbar = ['Edit''Delete''Search''Add''Update''Cancel'

      {
        text: 'Clear'tooltipText: 'Clear Search',
        prefixIcon: 'e-cancel'id: 'clear'align: 'Right'
      },
      {
        text: 'ExportData'tooltipText: 'ExportData',
        prefixIcon: 'e-cancel'id: 'export'align: 'Right'
      },
    ];




  
actionBegin(args) {
    // ExportService service;
    if (args.requestType == "delete") {
      this.onDeleteConfirm(args);
    }
    if (args.requestType == "save") {
      this.onSaveConfirm(args);

    }
//this event i want to call when i click on Export button
    if (args.requestType == "export") {
      this.exportRuleset(args)
    }
    

//this metho will call

exportRuleset(event) {
    this.rulesetService.exportRuleSet(event.data[0].ruleSetId).subscribe(
      result => {
        if (result.message != undefined && result.message == "ruleset does not contain any rules") {
          let initialState = {
            title: 'Export Ruleset',
            btn2: 'OK',
            body: 'Ruleset file does not contain any rules.',
            enableBtn2: true
          };
          this.bsModalRef = this.bsModalService.show(GlobalModalComponentObject.assign({ backdrop: trueignoreBackdropClick: truekeyboard: false }, { initialState }));
        }
        if (result.message != undefined && result.message == "ruleset not associated with job") {
          let initialState = {
            title: 'Export Ruleset',
            btn2: 'OK',
            body: 'Ruleset not associated with job. Please update ruleset and then export',
            enableBtn2: true
          };
          this.bsModalRef = this.bsModalService.show(GlobalModalComponentObject.assign({ backdrop: trueignoreBackdropClick: truekeyboard: false }, { initialState }));
        }
        if (result.message == undefined) {
          var filename = result.rulelist[0].ruleset.ruleSetName;
          const blob = new Blob([JSON.stringify(result)], { type: 'application/json' });
          fileSaver.saveAs(blobfilename);
        }
      }
    )
  }

 
 

1 Reply

SK Satheesh Kumar Balasubramanian Syncfusion Team July 30, 2021 12:15 PM UTC

Hi Sunil, 
  
Thanks for using Syncfusion Products. 
  
We have validated your reported query and suspect that you need to call exportRuleSet method in Grid’s actionBegin event on ExportExcel item click. But, actionBegin will not trigger on ExportExcel item click. So, we suggest you to use toolbarClick Event to call exportRuleSet method. For the same we have prepared a sample which can be viewed from the following link. 
  
  
app.component.ts: 
  toolbarClick(argsClickEventArgs): void { 
    switch (args.item.text) { 
      case 'ExportData': 
        this.exportRuleset(); 
        break; 
    } 
  } 
  actionBegin(argsany) { 
    console.log(args); 
  } 
  exportRuleset() { 
    //   Your code 
  } 
  
Kindly try the above sample and let us know if this works at your end. If you still face any problem, please share the below details to reproduce the issue which will help us to validate the issue and provide prompt solution as soon as possible. 
  • Share the above sample with modifying code to replicate the issue
  • Share issue replicating sample if possible
  • Share more details about calling exportRuleSet method in Grid’s actionBegin event

Regards,
Satheesh Kumar B


Loader.
Up arrow icon