How to format a date in a angular grid excel export ?

1 Answer 180 Views
Grid
Matt
Top achievements
Rank 1
Iron
Iron
Matt asked on 18 Oct 2022, 03:43 PM

I have tried many ways... I don't want to have to convert it to a string on the server.. The value coming back from the DateTime C# property is

2022-10-18T15:40:50.153345

 

 

 

 

So my template is

 <kendo-excelexport-column title="Training Approval Date" field="approvalDate" [cellOptions]="{ format: 'mm/dd/yyyy' }" [width]="200">
       

</kendo-excelexport-column>

 

 

But it doesnt format anything.. What is the right way to do this ?

 

 

 

1 Answer, 1 is accepted

Sort by
0
Svet
Telerik team
answered on 21 Oct 2022, 10:46 AM

Hi Matt,

Thank you for the provided details.

In general, all Kendo UI for Angular components that represent dates accept only dates as valid JavaScript Dates. That is due to the client-side nature of Kedno UI for Angular. Thus in order to be able to apply a format to the date it should first be converted from string to a JavaScript Date object. This can be done on the client side. For example, when the remote data is received on the client you can map it and convert any dates as required. Then pass the data to the Grid. I can also suggest the following knowledge base article on the matter:

https://www.telerik.com/kendo-angular-ui/components/knowledge-base/grid-handling-of-dates-format/

I hope the provided information helps.

Regards,
Svet
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Iron
Iron
Answers by
Svet
Telerik team
Share this question
or