• DateTextBox Popup Calendar

    By Ryan Buening 1 decade ago

     

    I'm wanting to make the popup calendar of the DateTextBox control open a month of my choosing...not the current month. This is possible with the Calendar dijit in Dojo 1.6 by using the currentFocus property:
    
     
    
    <?xml version="1.0" encoding="UTF-8"?>
    
    <xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    
    <xp:this.resources>
    
      <xp:dojoModule name="dijit.Calendar"/>
    
    </xp:this.resources>
    
    <div id="mycal"></div>
    
    <script>
    
      dojo.ready(function(){
    
      new dijit.Calendar({
    
      currentFocus: "2011/12/1"
    
      }, "mycal");
    
      });
    
    </script>
    
    </xp:view>
    
     
    
    How could I achieve this with the DateTextBox control's popup calendar as well? I tried adding a Dojo Attribute, but no success:
    
     
    
    <?xml version="1.0" encoding="UTF-8"?>
    
    <xp:view xmlns:xp="http://www.ibm.com/xsp/core" dojoTheme="true">
    
    <xp:this.resources>
    
    <xp:dojoModule name="dijit.form.DateTextBox"/>
    
    </xp:this.resources>
    
    <xp:inputText id="control" dojoType="dijit.form.DateTextBox">
    
    <xp:this.dojoAttributes>
    
    <xp:dojoAttribute
    
    name="currentFocus"
    
    value="2011/12/01">
    
    </xp:dojoAttribute>
    
    </xp:this.dojoAttributes>
    
    </xp:inputText>
    
    </xp:view>
    
     
    
    Any help is appreciated. Thanks.
    
    • Input text default value works for me

      By Simon McLoughlin 1 decade ago

            role="button" title="used to select a meeting date">
                    return "2005-12-30";
            }]]>

                    dojoType="dijit.form.DateTextBox">
            

            
                      dateStyle="short">
             

            

           

      • Can't Have a Default Value

        By Ryan Buening 1 decade ago

        Thanks for the reply. That does work, but I can't have a default value already selected. I just need the calendar popup to display a month that I set programmatically.

        • dojo doesn't seem to allow this

          By Simon McLoughlin 1 decade ago

           

          After some investigation from the dojo source and the online material from http://livedocs.dojotoolkit.org/dijit/form/DateTextBox

          it seems as though the date that the pop up focuses on is bound to the value that is set in the edit box and seems to have no way to set a "currentFocus" in the same way as just using the dijit.calendar.  Only setting the value or the default value causes the focus to shift from the current date.

          If your use case requires someone to actually select a date perhaps you could check if the date text box has been clicked instead of checking its value?