views:

90

answers:

3

I want a to user a DateChooser to allow a user to select a date in a given month and year. I want to set the month and year programmatically and only allow the user to select the date/day.

I can do this for the year easily by setting the minYear and maxYear to whatever year I want, but I am not seeing a strait forward way of disallowing the user to select a different month?

+1  A: 

You could also use the selectableRange property and set rangeStart and rangeEnd appropriately. Example to only allow user to pick from Aug 1 2010 to Aug 15 2010:

selectableRange="{{rangeStart:new Date(2010,7,1), rangeEnd:new Date(2010,7,15)}}"

However, note it'll still show the month navigator arrows (though they're disabled). I'm not sure if there's an easy way to hide those.

dowens
^ yes there is an easy to hide those. look at my answer.
Devtron
+1  A: 

mx:DateChooser out of the box allows only disabling of year navigation by public property "yearNavigationEnabled"

If you would like to disable month navigation too, you will have to extend from standard DateChooser component and implement "monthNavigationEnabled" functionality similar to existing "yearNavigationEnabled"

JabbyPanda
to properly fix the problem, yes you could extend. but why spend days,weeks, months re-inventing the wheel? use the CSS hack I posted.
Devtron
+1  A: 

Here is how you disable the month selection arrows...a total CSS hack!!

nextMonthUpSkin: ClassReference('mx.skins.Border');
nextMonthDisabledSkin: ClassReference('mx.skins.Border');
nextMonthDownSkin: ClassReference('mx.skins.Border');
nextMonthOverSkin: ClassReference('mx.skins.Border');
prevMonthUpSkin: ClassReference('mx.skins.Border');
prevMonthDisabledSkin: ClassReference('mx.skins.Border');
prevMonthDownSkin: ClassReference('mx.skins.Border');
prevMonthOverSkin: ClassReference('mx.skins.Border');   

I apologize for not seeing this question in August. But I recently (yesterday) had the same problem and found this solution...cheers.

Devtron
+1 yes, I meant to test this out when you first posted it but got side tracked. I tested this today and it worked great. Thanks.
John Isaacks
Sweet dude, glad it worked! I am not happy doing it this way, but I have 6 of these bad boys, full extended and color coding days, etc. Good luck!
Devtron