Announcement

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

    Today button in DateTimeItem form field

    GWT 2.5.0
    smartgwt 3.1
    Firefox 18.0

    Is there a way to not show the "Today" button in the DateChooser for the DateTimeItem form field ?

    I tried to do setAttribute("showTodayButton", false) hoping it will work but didn't. So I tried to create my own DateTimeField with my own DateChooser and was able to call setShowTodayButton to false to not show the "Today" button but encountered at least 3 issues so far, please see attachment that shows these issues:

    1). The date chooser always shows up at the top left corner. Tried doing setAutoShowParent(true) with no effect.

    2). The scroll bars appears on the side making it hard to choose the right most column. Tried doing setAutoHeight(), setAutoWidth(), DC.setOverflow(Overflow.VISIBLE), DC.setScrollbarSize(0) with no effect.

    3). The wrong month "Apr 2013" header displays initially; it should be "Aug 2013". The date is highlighted correctly though and when you click the next month arrow on the top, it will show "Sep" which is correct.

    Here is the sample test case:

    public class DateTimeTestCase implements EntryPoint {

    public void onModuleLoad() {
    DateTimeFormat formatter = DateTimeFormat.getFormat("yyyy-MM-dd'T'HH:mm:ss"); // Browser time zone is US/Pacific +08:00
    Date aDate = formatter.parse("2013-08-08T08:00:00");
    GWT.log("aDate: "+aDate);

    final DateTimeItemExt dateTime = new DateTimeItemExt();
    dateTime.setTitle("Date Time ");
    dateTime.setWrapTitle(false);
    dateTime.setDefaultChooserDate(aDate);

    final DynamicForm form = new DynamicForm();
    form.setAutoFocus(true);
    form.setHeight100();
    form.setWidth100();
    form.setPadding(25);
    form.setFields(dateTime);
    form.draw();
    }

    public class DateTimeItemExt extends DateTimeItem {

    private DateChooser DC = new DateChooser();
    private DateTimeItemExt myself;

    public DateTimeItemExt() {
    this.myself = this;

    DC.addDataChangedHandler(new DataChangedHandler(){
    @Override
    public void onDataChanged(
    com.smartgwt.client.widgets.events.DataChangedEvent event) {
    DC.hide();
    myself.setValue(DC.getData());
    }
    });

    DC.setShowTodayButton(false);
    DC.setShowCancelButton(true);
    DC.setCancelButtonTitle("Cancel");
    DC.setAutoShowParent(true);
    DC.setAutoHeight();
    DC.setAutoWidth();
    DC.setOverflow(Overflow.VISIBLE);
    DC.setScrollbarSize(0);

    PickerIcon datePicker = new PickerIcon(PickerIcon.DATE, new FormItemClickHandler() {
    @Override
    public void onFormItemClick(FormItemIconClickEvent event) {
    DC.show();
    }
    });

    setShowPickerIcon(false);
    setIcons(datePicker);
    }

    public void setDefaultChooserDate(Date date) {
    DC.setData(date);
    }
    }

    }

    So my customized date chooser is not working out for me but the built-in DateTimeItem form field is working except I just don't want to show the "Today" button.

    Please anyone, I am desparately need your help on this if you know a way like thru javascript to hide the "Today" button from the Date picker.

    Thank you very much in advance !
    Attached Files

    #2
    Update!

    With the latest nightly build of smartgwt 3.1p 2013-01-20,
    issue #3 has been fixed both in hosted and deploy mode
    Issue #2 only happens in hosted mode, deploy mode doesn't show scrollbar which is good.
    Issue #1 still desn't seem to have a solution to how to make the date picker to show up on top of the picker icon.

    Comment


      #3
      If you create your own DateChooser you need to position it yourself. Note that the formItem provides the rect where the FormItemIcon is displayed, so that you can position things over it (or near it).

      Comment

      Working...
      X