Uncaught (in promise) Format options or type given must be invalid for PDF export

Hi,

I have created a grid with PDF export and the export is failing with the error  Uncaught (in promise) Format options or type given must be invalid

I found that the error is because of date format I have given ie format="y/M/d
< e-grid-column field ="Date1" headerText ="Date" textAlign="Left" format="d/M/y" width="30"></e-grid-column>
If i choose the date format of yMd the export works fine. 

can you please let mw know how i can choose different date fromat then yMd for pdf export? 

Regards,
Chinmay

3 Replies

AG Ajith Govarthan Syncfusion Team March 30, 2020 11:09 AM UTC

Hi Chinmay, 

Greetings from Syncfusion. 

We have checked with the attached code snippet and found that you have customized the date as string type in the grid but the pdf export doesn’t support string type customization other than yMd format. So we have used the customFormat feature to customize the date format. We have attached the prepared sample so please refer the sample for your reference. 

Code Snippet:  
Index.cshtml 

        <e-grid-column field="OrderDate" headerText="Order Date" customFormat="@(new { type ="date", format="d/M/y" })" type="date" textAlign="Right" width="140"></e-grid-column> 

<script> 
    var gridObj; 
    function toolbarClick(args) { 
        gridObj = document.getElementById("Grid").ej2_instances[0]; 
        if (args.item.id === 'Grid_pdfexport') { 
            gridObj.pdfExport(); 
        } 
    } 

</script> 



Regards, 
Ajith G. 



JB Johan Bennink March 25, 2024 10:21 AM UTC

How is this still not fixed. The column has a format property, but to let this work with export you have to resort to adding a custom format.
And the error given does not indicate where the problem lies so you search and search. I did some cut-paste debugging and found out it was the date column, but this should be front and center when this type of restriction to otherwise valid properties is in effect!



VS Vikram Sundararajan Syncfusion Team March 28, 2024 02:20 PM UTC

Hi Johan Bennink,


Greetings from Syncfusion support,


We understand your concern regarding custom date formats during export. By default, our export functionality supports the 'columns.format' as a string, such as "yMd", for built-in date formats. However, when utilizing formats other than the default, a custom date format in object type is required.


To assist you further, we recommend referencing our documentation on exporting with custom date formats. Below is a snippet of code demonstrating how to implement this:


App.component.ts

 

  <e-column field='OrderDate' headerText='Order Date' [format]='formatOptions' width=100></e-column>

 

   ngOnInit(): void {

        this.formatOptions = { type: 'date', format: "d/M/y" };

    }

 


Documentation: https://ej2.syncfusion.com/angular/documentation/grid/pdf-export/pdf-export#exporting-with-custom-date-format


Please get back to us if you need further assistance.


Regards,

Vikram S



Loader.
Up arrow icon