Question

I am trying to do something which I think should be simple enough. I am using a datepickerfield in ST2.1 and trying to set the start date. I know I can set the year like so:

{
    xtype: 'datepickerfield',
    picker: {
        yearFrom: newDate().getFullYear(),
        yearTo: 1930
    }
}

but I also want to be able to set the start day and month. Is this possible? The above produces a result like 'January 1, 2013' and that is not what I want.

Was it helpful?

Solution

If you just want to set the initial date the picker comes up with, then you just want the value config attribute of the picker.

{
  xtype: 'datepickerfield',
  value: (new Date()), // the value in the actual input (will also be in the picker UI)
  picker: {
    value: (new Date()), // use this if you DON'T want/have a value in the actual input
    yearFrom: (new Date()).getFullYear(),
    yearTo: 1930
  }
}

Read more in the documentation (especially the "value" and "picker" config options). And here'a a Sencha Fiddle demonstrating usage.

OTHER TIPS

You can create monthFrom,monthTo and dayFrom,dayTo configs. But for that you need to extend Ext.picker.Date. Create appropriate configs for those field and change createSlots method to limit month and day values.

In response to your comment, you can have reorder slots with slotOrder config in picker. Like -

slotOrder:['day', 'month', 'year']

Once you extend Ext.picker.Date you can modify certain slot as you want and then can have full day name in first slot.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top