The code below has two very distinct behaviors if ran in SmartGWT 5 vs SmartGWT12.
In the first case when the button sets the value of the endDateTime item it is shown as relative interval (N Days from), while in SGWT 12 the endDateTime control will show a date.
In the first case when the button sets the value of the endDateTime item it is shown as relative interval (N Days from), while in SGWT 12 the endDateTime control will show a date.
Code:
protected RelativeDateItem startDateTime; protected RelativeDateItem endDateTime; protected TextItem txtItem = new TextItem(); protected Button setDate = new Button(); VLayout layout = new VLayout(); @Override public void onModuleLoad() { createStartAndEndDateTimes(); txtItem.setTitle("Value of Date to set"); txtItem.setValue("+5d"); setDate.setText("Apply Date to end Date"); setDate.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { endDateTime.setValue(txtItem.getValue()); txtItem.setValue(endDateTime.getDisplayValue()); } }); // add the items to the tool strip DynamicForm dateTimeForm = new DynamicForm(); dateTimeForm.setWidth(425); dateTimeForm.setNumCols(2); dateTimeForm.setWrapItemTitles(false); dateTimeForm.setFields(this.startDateTime, this.endDateTime, txtItem); layout.addMember(dateTimeForm); layout.addMember(setDate); layout.draw(); } /** * Method that can be overwritten on a per-market basis to allow for creation of {@link RelativeDateItem} objects * to be used for the start and end times. */ protected void createStartAndEndDateTimes() { //create the objects, set the types, and set the formatters this.startDateTime = new RelativeDateItem("startDateTime", "Start Time"); this.startDateTime.setTitleAlign(Alignment.CENTER); this.startDateTime.setType("datetime"); this.startDateTime.setUse24HourTime(true); this.endDateTime = new RelativeDateItem("endDateTime", "End Time"); this.endDateTime.setTitleAlign(Alignment.CENTER); this.endDateTime.setType("datetime"); this.endDateTime.setUse24HourTime(true); // set the default values and time units startDateTime.setShowFutureOptions(true); startDateTime.setTimeUnitOptions(TimeUnit.DAY, TimeUnit.HOUR); startDateTime.setValue(RelativeDate.TODAY); startDateTime.setShowPickerTimeItem(true); endDateTime.setShowFutureOptions(true); endDateTime.setTimeUnitOptions(TimeUnit.DAY, TimeUnit.HOUR); endDateTime.setValue("+5d"); endDateTime.setShowPickerTimeItem(true); }
Comment