Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DatePicker not allowing before 1995 and 2015

    I am not able to go beyond 1995 and 2015 if I select the date picker directly. If a date is entered in the field beyond this range, then the date picker shows the date. This is a problem with DOB fields and is probably a bug?

    I am using the 5/11/2012 LGPL nightly with GWT 2.3. Even GWT 2.4 didn't make any difference.

    Interestingly, the Showcase works fine, not sure how.

    Here's the sample code.
    Code:
    public void onModuleLoad() {
    
    		final VLayout layout = new VLayout(10);
    		final DynamicForm dateForm = new DynamicForm();
    		dateForm.setWidth(450);
    		dateForm.setIsGroup(true);
    		dateForm.setGroupTitle("Date Controls");
    
    		final DateItem dateItem = new DateItem();
    		dateItem.setTitle("Date");
    		dateItem.setHint("<nobr>Picklist based date input</nobr>");
    
    		final DateItem dateItem2 = new DateItem();
    		dateItem2.setTitle("Date");
    		dateItem2.setUseTextField(true);
    		dateItem2.setHint("<nobr>Direct date input</nobr>");
    
    		final TimeItem timeItem = new TimeItem("timeItem", "Time");
    
    		final DateRangeItem dateRangeItem = new DateRangeItem("dri", "Date Range");
    		dateRangeItem.setAllowRelativeDates(true);
    		final DateRange dateRange = new DateRange();
    		dateRange.setRelativeStartDate(RelativeDate.TODAY);
    		dateRange.setRelativeEndDate(new RelativeDate("-1m"));
    		dateRangeItem.setValue(dateRange);
    
    		final MiniDateRangeItem miniDateRangeItem = new MiniDateRangeItem("mdri", "Mini Date Range");
    		final RelativeDateItem relativeDateItem = new RelativeDateItem("rdi", "Relative Date");
    
    		dateForm.setItems(dateItem, dateItem2, timeItem, dateRangeItem, miniDateRangeItem, relativeDateItem);
    		layout.addMember(dateForm);
    		layout.draw();
    }
    Attached Files

    #2
    If you mean that direct text entry allows you to enter a date that could not be picked from the picker, this is by design and the reasoning behind it is covered in the docs for DateItem.startDate - use a dateRange validator to provide enforcement.

    Comment


      #3
      No the issue is for a date field, if I click on the date picker without entering any value in the date field, then navigate using the <<, I can only go till 1995 and not beyond that. I should be able to go to any previous date in the 1970s for example.

      See the attached screenshot, I could go only till Jan 1995 using the << and <, but after that it stays on Jan 1995 even if I click << or < further. Same issue with Dec 2015 if I use >> and >, can't go beyond Dec 2015.

      Comment


        #4
        That's what setStartDate() and setEndDate() are for.

        Comment


          #5
          Thanks. Curious how is the showcase working fine, I don't see the setStart/EndDate() methods being called in the sample that comes with the jars.

          Comment


            #6
            Is there some way to setStartDate/EndDate globally? We'd like all date prompts to allow scrolling beyond 2015.

            Comment


              #7
              setDefaultProperties() can be used to change defaults on components.

              Comment


                #8
                I put this in my entrypoint class but I'm not seeing any difference in the chooser. It still stops at 2015. Is there more to it.

                DateChooser dateChooserTemplate = new DateChooser();
                dateChooserTemplate.setStartYear(1900 + new Date().getYear() - 10);
                dateChooserTemplate.setEndYear(1900 + new Date().getYear() + 10);
                DateChooser.setDefaultProperties(dateChooserTemplate);

                Comment


                  #9
                  That will work to change dates for standalone DateChoosers, but if you want to affect the DateChooser automatically lauched by DateItems, you'll need to set the startDate and endDate for DateItem instead (or as well).

                  Comment


                    #10
                    I don't see any method for DateItem.setDefaultProperties().

                    Comment


                      #11
                      We'll make sure this gets added.
                      In the meantime you can do this via JSNI:

                      Code:
                          private native void setDefaultDateRange (JavaScriptObject startDateJS, JavaScriptObject endDateJS) /*-{
                              $wnd.isc.DateItem.addProperties({
                                  startDate:startDateJS,
                                  endDate:endDateJS
                              });
                          }-*/;
                      Then call this as follows:
                      Code:
                              JavaScriptObject startDateJS = JSOHelper.getJSLogicalDate(new Date(1900,0,1));
                              JavaScriptObject endDateJS = JSOHelper.getJSLogicalDate(new Date(2013,0,1));
                              setDefaultDateRange(startDateJS, endDateJS);
                      Regards
                      Isomorphic Software

                      Comment


                        #12
                        Hi all,

                        now it's 2014 and the DateChooser in lib smartgwt-4.0.0p20140105.jar still have 2015 as default of endYear.

                        Are you planning to change this default in the near future?

                        Thank you
                        Barbara

                        Comment


                          #13
                          We've just updated the defaults for DateItem and DateChooser to cover dates from 1995 to 2020. See previous posts for how to set them yourself.

                          Comment


                            #14
                            Thank you Isomorphic,

                            I had already overwrite default in my application using the code suggested and it works just fine.

                            Barbara

                            Comment


                              #15
                              Hello,

                              This works indeed, but only for the datepicker in DynamicForms and ListGrids. It seems to still not work in the filters above the grids (those date range widgets). Is there any way to fix it in those?

                              PS. i'm still using 3.1, latest nightly.

                              Comment

                              Working...
                              X