[Solved] - How to using double click event to export data?

Hi, 
I want to use double click to export the selection instead edit row, however I cannot set up an event for double click.
How do I change this?
Thanks you!


3 Replies

SS Susmitha Sundar Syncfusion Team May 8, 2020 01:34 PM UTC

Hi GridLock, 
 
Thank you for using Syncfusion controls. 
 
You can achieve your requirement by using the SfDataGrid.CellDoubleClick event. You can restrict the editing for double click using SfDataGrid.AllowEditing as false. Please refer the below code, 
 
this.sfDataGrid1.AllowEditing = false; 
 
this.sfDataGrid1.SelectionMode = GridSelectionMode.Multiple; 
 
this.sfDataGrid1.CellDoubleClick += SfDataGrid1_CellDoubleClick; 
 
private void SfDataGrid1_CellDoubleClick(object sender, CellClickEventArgs e) 
 { 
     //Export to PDF 
     PdfExportingOptions pdfoptions = new PdfExportingOptions(); 
     pdfoptions.AutoColumnWidth = true; 
     var document = sfDataGrid1.ExportToPdf(sfDataGrid1.SelectedItems, pdfoptions); 
     document.Save("Sample.pdf"); 
 
     //Export to Excel 
     var exceloptions = new ExcelExportingOptions(); 
     ExcelEngine excelEngine = new ExcelEngine(); 
     IWorkbook workBook = excelEngine.Excel.Workbooks.Create(); 
     workBook.Worksheets.Create(); 
     sfDataGrid1.ExportToExcel(sfDataGrid1.SelectedItems, exceloptions, workBook.Worksheets[0]); 
     workBook.Version = ExcelVersion.Excel2013; 
     workBook.SaveAs("Sample.xlsx"); 
 } 
 
 
 
 
Please check the sample and let us know if you need further assistance on this. 
 
Regards, 
Susmitha S 



TG The GridLock May 8, 2020 02:52 PM UTC

Hi Susmitha, 
I missed it.. Works well for me now!



SS Susmitha Sundar Syncfusion Team May 13, 2020 04:21 AM UTC

Hi khanh dang, 
 
Thanks for the update. 
 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Susmitha S 


Loader.
Up arrow icon