Reputation: 1047
I have a kendo grid with a date column. In order to format the date, I'm using:
format: {0: dd/MM/yyyy }
.
All is well, until I try updating the data source of the grid:
chargesDS.data(ko.toJS(newValue));
chargesDS.sync();
chargesGrid.refresh();
the .data() call (first line) breaks the date column, causing the format to go back to some default format.
Is there a way to refresh the grid so that the dates are displayed properly again?
Upvotes: 2
Views: 994
Reputation: 1047
For anyone who ends up here: I got around the problem by using a template:
function KendoDateTemplate (dateFormat, propertyName) {
var temp =
"#= " + propertyName + " ?" + //is the date non-null? if yes, parse. If no, show empty string.
"kendo.toString(kendo.parseDate(moment(" + propertyName + ").toDate(), 'yyyy-MM-dd'), '" + dateFormat + "' ) " +
" : \"\" #"; //second half of tertiary exp
return temp;
};
...and in the grid options:
{
field: "DateField", title: "Date",
template: KendoDateTemplate('MM/dd/yyyy', 'DateField')
}, ...
Upvotes: 0