Format kendo-ui-angular2 grid date column using pr

2019-07-15 05:05发布

问题:

Was wondering if it is possible to format a date in a column using a property. E.g:

<kendo-grid-column field="DOB" format="{0:d}" title="DOB" width="160"  >
    </kendo-grid-column>

I would like to format the DOB using a property. In my TS file I would have something like:

shortDate="dd/mm/yyyy"

In HTML:

<kendo-grid-column field="DOB" format="{0:shortDate}" title="DOB" width="160"  >
    </kendo-grid-column>

Something like that possible?

Thanks,

回答1:

Solution I ended up using:

<kendo-grid-column field="DOB" title="DOB" width="160" >
        <ng-template kendoGridCellTemplate let-dataItem>
            {{dataItem.DOB | date:config.ShortDate}}
        </ng-template>
    </kendo-grid-column>


回答2:

For anyone in future's use, You can easily format it using below format property as below

<kendo-grid-column title="Received On" field="labReceivedDate" format="{0: dd MMM yyyy}" width="120px "></kendo-grid-column>