Date column format

I have been trying to format a date column. Your standard syntax, like "yMd", "d" and "y" are working.
However, when trying to apply a custom format, the grid appears to not show any data, without any errors.
I have tried several approaches like "format='dd/MM/yyyy'" or "format='{0:dd/MM/yyyy}'" and none seem to work.
Is there a syntax I am missing? How can we make this happen?

4 Replies

VA Venkatesh Ayothi Raman Syncfusion Team March 12, 2018 07:37 AM UTC

Hi Alexandros, 

Thanks for using Syncfusion products. 

We went through your code example that you have shared for us and found that you are applying a jQuery date formats to EJ2-Grid. But we have used the Unicode CLDR for formatting and parsing date and number objects. Please refer to the following Help documentation for more information, 
So, we can achieved your requirement by using custom format future in the “column.format” property. Please refer the following code example and documentation link.  Please refer to the sample, 
__<ejs-grid [dataSource]='data' height="315px"> 
    <e-columns> 
                 . .   .  
        <e-column field='OrderDate' type='date' headerText='Order Date' textAlign='Right' [format]='formatOptions' width=120></e-column> 
    </e-columns> 
</ejs-grid> 
 
[ts] 
export class AppComponent implements OnInit { 
 
    public data: Object[]; 
    public formatOptions:any; 
    ngOnInit(): void { 
        this.data = data; 
        this.formatOptions={type:'date',format:"dd/MM/yyyy"}; 
    } 
} 


Regards, 
Venkatesh Ayothiraman. 



AG Alexandros Ginakos March 12, 2018 09:09 AM UTC

Hello Venkatesh,

Works like a charm. Your response was quick and to the point. Thank you.

Regards,
Alex


IR Isuriya Rajan Syncfusion Team March 13, 2018 06:09 AM UTC

Hi Alex, 
We are happy to hear your problmes has been resolved. 
  
Regards, 
Isuriya R 



JP Jan Poljovka May 25, 2018 08:03 AM UTC

Hi Isuriya,

when I format datetime column in angular grid like you proposed in answer to Alexandros with [format]='formatOptions' in html code
and this.formatOptions={type:'date',format:"dd/MM/yyyy"};  in ts code, Export to Excel functionality does not work
(when I click on the export button nothing happens, no error is rendered in browser console)
while export to pdf works normaly.

Loader.
Up arrow icon