Hi All
Im trying to format a date of 2016-06-11T16:20:00.0000000 to 2016-06-11 16:20
Below is the code in my HTML inside a p-column field
<p-column field="date | date : 'dd/MM/yy HH:mm:ss'" header="Date" [sortable]="true"></p-column>
Has anyone any guidance on this?
Thanks
Format Date in p-dataTable
Tom,
A <p-column> is not angular expression, so pipes and filters do not affect the values you put in there. The field expression is a string value that p-column will use to look up (i.e.: hash table reference) from the context of the column. To do what you're looking for you need to use a content template for the p-column.
Please note you'll need Angular2 updated to RC2 to make the date formatting work the way you want.
A <p-column> is not angular expression, so pipes and filters do not affect the values you put in there. The field expression is a string value that p-column will use to look up (i.e.: hash table reference) from the context of the column. To do what you're looking for you need to use a content template for the p-column.
Code: Select all
<p-column field="date" header="Date" [sortable]="true">
<template let-col let-data="rowData">
<span>{{data.date | date: 'dd/MM/yy HH:mm:ss'}}</span>
</template>
</p-column>
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
+1 for pipes
-
- Posts: 1
- Joined: 13 Jul 2017, 12:26
Hi,
I am trying to format decimal number using the same approach suggested by you, but it is not working. Please help.
<p-datatable [value]="positions"
<p-column field="amount" header="Date" [sortable]="true">
<template let-col let-data="rowData">
<span>{{ data.amount| number: '3.2-5'}}</span>
</template>
</p-column>
</p-datatable>
I am trying to format decimal number using the same approach suggested by you, but it is not working. Please help.
<p-datatable [value]="positions"
<p-column field="amount" header="Date" [sortable]="true">
<template let-col let-data="rowData">
<span>{{ data.amount| number: '3.2-5'}}</span>
</template>
</p-column>
</p-datatable>
-
- Information
-
Who is online
Users browsing this forum: No registered users and 27 guests