when i select row and click on toolbar custom export button then i want to call actionBegin event

My requirement is when i select specific row and clicked on ExportData  cutomize button present in toolbxx then i want to call actionBegin event.


when i select specific  row and click on toolbar custom export button then i want to call actionBegin event 


 this.editSettings = { showDeleteConfirmDialog: trueallowEditing: trueallowAdding: trueallowDeleting: true };
    this.toolbar = ['Edit''Delete''Search''Add''Update''Cancel'

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

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

    }
//here i want to call this event when click on ExportData button

    if (args.requestType == "export") {
      this.exportRuleset(args)
    }
    
  }
\
if not possible then provide some alternative solutions






3 Replies

SK Sujith Kumar Rajkumar Syncfusion Team August 2, 2021 11:35 AM UTC

Hi Sunil, 
 
Greetings from Syncfusion support. 
 
We are not able to clearly understand your requirement from the provided information. So please share us the following details to understand it better, 
 
  • The actionBegin event will be triggered when performing Grid actions like, Page, Filter, Sort, etc., and not on clicking custom toolbar buttons. So please let us know why you need to call the actionBegin event for this case.
 
  • If your requirement is to trigger an event on clicking the custom toolbar button, then we suggest you to use the Grid’s toolbarClick event.
 
 
If your requirement does not come under the above case, then please elaborate on it based on which we will validate from our end share the further details. 
 
Regards, 
Sujith R 



SU sunil August 2, 2021 12:20 PM UTC

when i select specific row based on rowid then if i click on toolbar customized button then i want to file in json format 



SK Sujith Kumar Rajkumar Syncfusion Team August 3, 2021 09:15 AM UTC

Hi Sunil, 
 
Based on the provided information we could understand that your requirement is to export only the selected record in Grid on toolbar button click. You can achieve this requirement by providing the selected records JSON data as custom data source to the excel export or pdf export properties as demonstrated in the below code snippet, 
 
// Grid’s toolbarClick event handler 
toolbarClick(args: ClickEventArgs): void { 
    if(args.item.text === "PDF Export") { 
        // Retrieves selected record JSON data  
        var selectedRecords = this.grid.getSelectedRecords(); 
        if (selectedRecords.length !== 0) { 
            // The selected record data is set to the export’s dataSource property and passed along with the pdfExport method 
            let exportProperties = { 
                dataSource: selectedRecords, 
            }; 
            this.grid.pdfExport(exportProperties); 
        } else { 
            // If no records are selected, then the entire data is exported 
            this.grid.pdfExport(); 
        } 
    } else if (args.item.text === "Excel Export") { 
        // The same approach can be used for excel export 
    } 
} 
 
We have prepared a sample based on this for your reference. You can find it below, 
 
 
More details on this can be checked in the below documentation links, 
 
                               https://ej2.syncfusion.com/angular/documentation/grid/excel-exporting/#custom-data-source 
 
 
Let us know if you have any concerns. 
 
Regards, 
Sujith R 


Loader.
Up arrow icon