I am not understanding how to customize the date formatting on a SelectItem. I have it partially working, with ListGrid for the pick list using a CellFormatter and com.google.gwt.i18n.client.DateTimeFormat, but the actual display (once picked) does not use the customization.
In the pick list ListGrid, the date is formatted as I want it to be (e.g. Friday, June 17, 2011), how do I make the SelectItem show this format once the day is selected?
Code:
public static final CellFormatter broadcastDayCellFormatter = new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum)
{
final DateTimeFormat dateFormatter = DateTimeFormat.getFormat("EEEE, MMMM d, y");
return dateFormatter.format((Date) value);
}
};
private DynamicForm buildDaySelectForm()
{
final DynamicForm form = new DynamicForm();
form.setWidth100();
form.setTitleSuffix("");
form.setNumCols(1);
ListGridField dateField = new ListGridField("broadcast_date");
dateField.setCellFormatter(broadcastDayCellFormatter);
broadcastDaySelectItem = new SelectItem("broadcast_date", "Day");
broadcastDaySelectItem.setShowTitle(false);
broadcastDaySelectItem.setWidth("*");
broadcastDaySelectItem.setDefaultToFirstOption(true);
broadcastDaySelectItem.setRedrawOnChange(true);
broadcastDaySelectItem.setPickListFields(dateField);
// code snipped...
form.setFields(broadcastDaySelectItem);
return form;
}
Comment