My code
Code
JavaScript
function onToolbarClick(args) {
switch (args.item.id) {
case 'excelExport':
ExcelExport();
break;
case 'pdfExport':
PdfExport();
break;
}
}
function ExcelExport() {
const gridObj = document.getElementById("GridFilteredInstrumentSampleData").ej2_instances[0];
const excelExportProperties = {
fileName: "RadGridExport.xlsx"
};
gridObj.excelExport(excelExportProperties);
}
function PdfExport() {
const gridObj = document.getElementById("GridFilteredInstrumentSampleData").ej2_instances[0];
const pdfExportProperties = {
fileName: "RadGridExport.pdf",
allowGrouping: true, // Ensure grouping is enabled during export
group: gridObj.groupModule.groupSettings.columns, // Pass current group settings
theme: {
header: {
fontColor: '#000000',
fontName: 'Calibri',
fontSize: 8,
bold: true,
fillColor: '#CCCCCC'
},
record: {
fontColor: '#000000',
fontName: 'Calibri',
fontSize: 8
}
},
columns: [
{ field: 'FacilityName', headerText: 'Facility Name', width: 60 },
{ field: 'InstrumentName', headerText: 'Instrument Name', width: 80 },
{ field: 'NumberOfSample', headerText: 'No. Of Samples', width: 60 },
{ field: 'RequisitionStatus', headerText: 'Requisition Status', width: 80 },
{ field: 'CreatedOn', headerText: 'CreatedOn', width: 60, format: { type: 'date', format: 'dd-MM-yyyy' } }
],
allowPageBreaks: true,
pageSize: 'A4',
pageOrientation: 'Portrait',
height: 'auto'
};
gridObj.pdfExport(pdfExportProperties);
}Allow Pdf Export Not Working please Resolve

Naimish MakwanaRank #324 · 7.7K reputationPosted Aug 28, 2024, 2:05 AM EDT
To resolve the issue where the PDF export is not working in your
ejs-grid, let's review and adjust your code. The issue might stem from either the grid configuration or the JavaScript logic for exporting the PDF.Steps to Resolve the Issue:
Ensure the Required Scripts Are Included: Make sure that all necessary scripts for PDF export are included in your page, especially
ej2.min.jsandpdf-export.min.js.Verify the Grid ID: Ensure that the
GridFilteredInstrumentSampleDataID is correct and matches what you're referencing in your JavaScript.Correct the PDF Export Code: Let's refine the
PdfExportfunction to ensure everything is correctly configured.Here's an updated version of your JavaScript:
function onToolbarClick(args) { switch (args.item.id) { case 'excelExport': ExcelExport(); break; case 'pdfExport': PdfExport(); break; } } function ExcelExport() { const gridObj = document.getElementById("GridFilteredInstrumentSampleData").ej2_instances[0]; const excelExportProperties = { fileName: "RadGridExport.xlsx" }; gridObj.excelExport(excelExportProperties); } function PdfExport() { const gridObj = document.getElementById("GridFilteredInstrumentSampleData").ej2_instances[0]; const pdfExportProperties = { fileName: "RadGridExport.pdf", theme: { header: { fontColor: '#000000', fontName: 'Calibri', fontSize: 10, bold: true, backgroundColor: '#CCCCCC' }, record: { fontColor: '#000000', fontName: 'Calibri', fontSize: 9 } }, // Adjust the columns to match those in the grid columns: [ { field: 'FacilityName', headerText: 'Facility Name', width: 120 }, { field: 'InstrumentName', headerText: 'Instrument Name', width: 150 }, { field: 'NumberOfSample', headerText: 'No. Of Samples', width: 120 }, { field: 'RequisitionStatus', headerText: 'Requisition Status', width: 150 }, { field: 'CreatedOn', headerText: 'Created On', width: 120, format: { type: 'date', format: 'dd-MM-yyyy' } } ], allowPageBreaks: true, pageOrientation: 'Portrait', pageSize: 'A4' }; gridObj.pdfExport(pdfExportProperties); }Key Adjustments:
themesettings to ensure consistency across all exported documents.Additional Checks:
If after these adjustments the issue persists, please share any error messages or behavior you observe during the PDF export attempt.
Mithun Pradhan194 reputationPosted Aug 28, 2024, 2:12 AM EDT
Error Massage
ej2.min.js:10Uncaught (in promise)
Mithun Pradhan194 reputationPosted Aug 29, 2024, 1:16 AM EDT
Error Massage
ej2.min.js:10Uncaught (in promise)
Aman GuptaRank #193 · 12.4K reputationPosted Aug 28, 2024, 12:46 PM EDT
Hi Mithun,
To address a common issue faced when attempting to export data to PDF using the Syncfusion EJ2 Grid component in an ASP.NET application.
Check Required Scripts and Styles: Ensure that all necessary Syncfusion EJ2 scripts and styles are included in your project. The PDF export functionality requires certain dependencies, such as pdfmake, jszip, and other Syncfusion scripts.
Modify the PDF Export Function: The PdfExport function might need adjustments to correctly handle grouping and other settings. Here’s an updated version of your PdfExport function:
function PdfExport() { const gridObj = document.getElementById("GridFilteredInstrumentSampleData").ej2_instances[0]; const pdfExportProperties = { fileName: "RadGridExport.pdf", allowGrouping: true, // Ensure grouping is enabled during export groupSettings: { columns: gridObj.groupModule.groupSettings.columns }, // Corrected group settings theme: { header: { fontColor: '#000000', fontName: 'Calibri', fontSize: 8, bold: true, fillColor: '#CCCCCC' }, record: { fontColor: '#000000', fontName: 'Calibri', fontSize: 8 } }, columns: [ { field: 'FacilityName', headerText: 'Facility Name', width: 60 }, { field: 'InstrumentName', headerText: 'Instrument Name', width: 80 }, { field: 'NumberOfSample', headerText: 'No. Of Samples', width: 60 }, { field: 'RequisitionStatus', headerText: 'Requisition Status', width: 80 }, { field: 'CreatedOn', headerText: 'CreatedOn', width: 60, format: { type: 'date', format: 'dd-MM-yyyy' } } ], allowPageBreaks: true, pageSize: 'A4', pageOrientation: 'Portrait', height: 'auto' }; gridObj.pdfExport(pdfExportProperties); }Ensure Correct Grouping Settings: The groupSettings in the pdfExportProperties should be properly set to handle the current grouping in the grid. The code above has been adjusted to use groupModule.groupSettings.columns.
Update Syncfusion and Dependencies: Ensure that you are using the latest version of Syncfusion EJ2 and other related libraries like pdfmake. Compatibility issues can sometimes cause export functions to fail.
Check for JavaScript Errors: Open your browser’s developer tools (usually by pressing F12) and check for any JavaScript errors in the console that might provide more information on what’s going wrong.
Verify Server-Side Configuration: Ensure that your server-side configuration allows for file exports. This includes checking permissions and ensuring that the server environment supports the generation and serving of PDF files.
Conclusion:
By following these steps, you should be able to resolve the issue with PDF export in the Syncfusion EJ2 Grid. The key is ensuring that all necessary scripts are included, the export properties are correctly configured, and that the server environment is properly set up to handle PDF exports.