2 Replies Latest reply on Sep 4, 2009 8:59 AM by Prabh Singh

    Datefield minYear not working correctly

    Prabh Singh

      Hello,

       

      I have a datefield. and I am trying to set the minYear property as shown below but it does not seem to be working and it lets me go all the way to the default value of 1900. maxYear works perfectly fine.

       

      Is there a workaround ?

      This does not work as it should:
      <mx:DateField minYear="{yearToday}" maxYear="{yearToday+2}"/>
      *)

       

      yearToday is an int variable containing the 4 digit value of the current 
      year, in this case, 2009.

      The maxYear is set, I cannot navigate more than 2 years above the current 
      year, but minYear does not work and allows me to navigate until the default 
      value of 1900.

       

      thanks in advance

      Prabh

        • 1. Re: Datefield minYear not working correctly
          Andrew Rosewarn Level 3

          Hi

           

          Yea thats odd looks like a bug. 2 things I guess, you could disable all the dates prior to 1st Jan 09

           

          <mx:DateField x="145" y="104" disabledRanges="{[{rangeEnd: new Date(2009, 0, 1)} ]}"/>

           

          or the DateField has an event called scroll which triggers when the months are navigated.  You could listen for that and if the selected date is less than 1st jan 09 then set the selection back to Jan 09.

           

          I think the first would probably be cleaner and would stop the user inputting the date you don;t want.

           

          Hope this helps

           

          Andrew

          1 person found this helpful
          • 2. Re: Datefield minYear not working correctly
            Prabh Singh Level 1

            Thanks for the reply Andrew.

             

            I haven't tried what you suggested yet. But I was playing with what I had earlier and came across something really interesting..

             

            1. If the value of minYear and maxYear are the same. The bug gets introduced. No matter if the value is hardcoded.

            e.g. <mx:Datefield minYear = "2009" maxYear = "2009"/> OR <mx:Datefield minYear = "{year}" maxYear = "{year}"/>

            where year is an int value say 2009.

             

            2. If we do an operation on the minYear and maxYear this starts working.

            e.g. <mx:Datefield minYear = "{year + 2}" maxYear = "{year + 2}"/>

             

            This is extremely weird and very frustrating.

             

            And came across another thing. If you make the value of minYear greater than maxYear by 1. The datefield gives the correct output as it should for ---> <mx:Datefield minYear = "2009" maxYear = "2009"/>

             

            I think I should report the bug. Spent too much time on it and has driven me nuts.