Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format date in Angular Kendo Grid

I working on Angular Kendo Grid and I am getting server data in format

1900-01-01T00:00:00

But I want it to display in standard format, not sure how to do it. I have applied format='{0:MM/dd/yyyy h:mm a}' in grid column but no effect. What ever data format conversion to do, I need to do at client side of code i.e server date to javascript format!!

<kendo-grid-column field="mydata.openDate" width="220" title="Open Date" filter="date" 
                   format='{0:MM/dd/yyyy h:mm a}'>
</kendo-grid-column>
like image 302
K.Z Avatar asked Oct 17 '18 11:10

K.Z


2 Answers

Try this:

<kendo-grid-column field="dateField" width="220" title="Open Date">
    <ng-template kendoGridCellTemplate let-dataItem>
        {{dataItem.dateField | date: 'MM/dd/yyyy'}}
    </ng-template>
</kendo-grid-column>

You can also use short or other formats provided by angular Date Pipe

like image 185
alchi baucha Avatar answered Oct 31 '22 04:10

alchi baucha


The Grid data needs to contain actual JavaScript Date objects as opposed to some string representations. Then built-in formatting, sorting, filtering and editing will treat the dates as such and will work as expected:

Docs

Map the data so that it contains actual dates.

EXAMPLES:

String Date

like image 42
saumil_ Avatar answered Oct 31 '22 06:10

saumil_