My framework uses moment.js for datetime values which return values in ISO dateformat. I have managed to format the correct datetime values in the grid by calling a function in my controller:
<kendo-grid-column field=
"creationTime"
title=
"{{ l('CreationTime')}}"
width=
"150"
[hidden]=
"false"
media=
"lg"
>
<ng-template kendoGridCellTemplate let-dataItem>
{{ formatDate(dataItem.creationTime) }}
</ng-template>
</kendo-grid-column>
And my function:
formatDate(date: any) {
return
moment(date).format(
'L'
);
}
The problem is that the filter now sees the data as a string and therefore I get the string filter. I have exhaustively searched the forums on how to set the ISO date value to a javascript Date value and find myself scratching my head because all of the examples are either JQuery or angular with rxjs prior to angular 5.5.
So, I have the following method where this.gridData is a GridDataResult which is bound to my grid:
getEntitiesForKendo() {
this
.gridLoading =
true
;
this
._kendoGridService.getEntities(
this
.state)
.subscribe((data) => {
this
.gridData = data;
this
.getOrganisationUnits();
this
.gridLoading =
false
;
});
}
Which works great but a datetime value in this.gridData I have to use a function to convert to datetime in the grid column. It would be better to cast the ISO date value to a javascript value so the grid can understand it but so far my investigations shjow that the only advice from Kendo is that I have to cast the value:
data.datetimevalue =
new
Date(data.datetimevalue)
In the subscription to my observable how do I get to the datetime value and cast it?
I have tried both the pipe and map operators to no avail. Surely the conversion of ISO datetime values to javascript values is common? Can anyone give me any pointers? At the moment (sic.) I have had to disable filters on the datetime column which is not really what I want.