Skip to content

Instantly share code, notes, and snippets.

@branflake2267
Last active April 19, 2017 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save branflake2267/c5c7a9875706c529fde4cb9af182747d to your computer and use it in GitHub Desktop.
Save branflake2267/c5c7a9875706c529fde4cb9af182747d to your computer and use it in GitHub Desktop.
GXT 4 custom date picker and custom date picker selection styles
import java.util.Date;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.datepicker.client.CalendarUtil;
import com.sencha.gxt.cell.core.client.form.DateCell;
import com.sencha.gxt.widget.core.client.DatePicker;
import com.sencha.gxt.widget.core.client.event.ExpandEvent;
import com.sencha.gxt.widget.core.client.event.ExpandEvent.ExpandHandler;
import com.sencha.gxt.widget.core.client.form.DateField;
import com.sencha.gxt.widget.core.client.menu.DateMenu;
public class DateFieldWithCustPickerFocus implements EntryPoint {
@Override
public void onModuleLoad() {
final Date minValue = new Date();
CalendarUtil.addDaysToDate(minValue, 30);
final Date maxValue = new Date();
CalendarUtil.addDaysToDate(maxValue, 70);
DatePicker picker = new DatePicker();
DateMenu dateMenu = new DateMenu(picker);
DateCell cell = new DateCell();
cell.setMenu(dateMenu);
DateField field = new DateField(cell);
field.setMinValue(minValue);
field.setMaxValue(maxValue);
field.addExpandHandler(new ExpandHandler() {
@Override
public void onExpand(ExpandEvent event) {
final Date futureDate = new Date();
CalendarUtil.addDaysToDate(futureDate, 30);
picker.setValue(futureDate, false);
}
});
// field.setValue(future);
RootPanel.get()
.add(field);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment