How to submit the formatted datepickerfield value in Sencha Touch 2

If you are used to Ext JS then sometimes Sencha Touch is quite annoying in missing some features that makes life a bit easier. When submitting a form to the server, Ext JS has on a datefield the config option submitFormat. With this option you can simply submit the date in the format that you want, like 14.10.2013 instead of 2013-10-14T00:00:00.

Sencha Touch doesn’t have this option on a datepickerfield, so we have to trick a bit. We add 2 fields to the form, one is the datepickfield and the other is a hidden field (that is submitted automatically, unlike Ext JS). The configuration looks then like this:

The configuration in the form

As you can see the listener will now update the hidden field to the formatted value. On the server you can use the field you like. Not very nice, but it works. The result looks something like this:

End result (as shown in Chrome)

image

Johan van de Merwe
Dedicated to professional software development since 1985. Has worked since 1992 as IT manager in several international operating companies. Since 2007 CEO and Sencha Ext JS web application developer at Enovision GmbH.

Comments

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.