Reputation: 16847
I have a datepicker
in my form and it gets the value from the form.load in JSON format.
Which values does the datepicker support?
Because it won't bind this value:\/Date(1241215200000)\/
.
I already have a convert function for the JSON format but I can't configure the field with a convert
or renderer
config.
convertDate = function (value) {
if (value == null) return null;
return new Date(parseInt(value.replace("/Date(", ""), 10));
};
Upvotes: 1
Views: 548
Reputation: 23973
The value have to be a valid JavaScript date or Ext.Date
. So you should bind it like
new Date(1241215200000)
For example the Newtonsoft JSON serializer is capable of returning this for a given date. But if all fails you may consider overriding the setValue()
of the picker and apply your converter there
Below is only valid for Ext.field.Date
(My first but wrong answer for a datepicker)
I recommend you to use the ISO 8601 date
format for your dates. With that you need to set the submitFormat to c
submitFormat: 'c'
Tools like Newtonsoft.Json support the ISO 8601 date
out of the box (and since .Net 4.5 release 1 as default).
Upvotes: 1