PDA

View Full Version : Using a different calendar for DatePicker control



zoran.lisovac@gmail.com
27 Aug 2015, 9:46 PM
Hi,

I'm using Ext.form.DateField control for date picker. I'm wondering if there is a way to use a different calendar as a base for date picker? In other words, I'd like to have some sort of localization. If the language is english, display Gregorian calendar from DatePicker. If the language is Arabic, use Hirji calendar.

I also tried to just override month day names like this:

https://www.sencha.com/forum/showthread.php?89113-Localization-of-DatePicker-short-month-names

but that won't work since in hirji calendar years differ from gregorian calendar.
There is also Jquery's implementation of different calendars:

http://keith-wood.name/calendars.html

is there a way to somehow use jquery's calendar with Ext's datepicker?
If no, any way how could I achieve this?

joel.watson
29 Aug 2015, 12:03 PM
Hi--

Out of the box, this isn't possible to configure the built in date picker field to do this.

However, it's conceivably possible to create your own date picker field. By extending Ext.form.field.Picker, you could provide your own createPicker() method in which you could initialize the custom date picker that you'd like to use. From there, you'd have to wire up whatever calendar you're using so that various events (such as selections) would be properly communicated to the underlying picker field so that it would behave like the default date field. This will require a lot of customization--if you go down this road, I'd strong encourage you to study the contents of these three classes thoroughly:

http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Picker
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Date
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.picker.Date

I hope that helps give you a good place to start--thanks!
Joel