View Full Version : TimeField.setFormat() does not work
andreiastra
23 Jul 2010, 3:40 AM
Hi,
I'm trying to change the time format for a Time Field by calling setFormat(). It does not do anything.
Next, I tried to use
timeField.setPropertyEditor(propertyEditor);
It does change the format in the field, but the values in the pull-down list do not change the format, see picture:
21619
Should I call some kind of refresh function to make the format change visible?
It there any way to fix the problem?
Thank you,
Andrei
andreiastra
23 Jul 2010, 3:45 AM
public
class TimeFieldTest implements EntryPoint {
staticintcount = 0;
publicvoid onModuleLoad() {
Viewport viewport = new Viewport();
viewport.setLayout(new BorderLayout());
HorizontalPanel horizontalPanel = new HorizontalPanel();
horizontalPanel.setSpacing(10);
final TimeField timeField = new TimeField();
timeField.setTriggerAction(TriggerAction.ALL);
horizontalPanel.add(timeField);
Button button = new Button("Ok");
horizontalPanel.add(button);
button.addListener(Events.OnClick, new Listener<ButtonEvent>() {
publicvoid handleEvent(ButtonEvent be) {
final DateTimeFormat dateTimeFormat = count++ % 2 == 0 ? DateTimeFormat
.getMediumTimeFormat() : DateTimeFormat.getShortTimeFormat();
ListModelPropertyEditor<Time> propertyEditor = new ListModelPropertyEditor<Time>() {
@Override
public Time convertStringValue(String value) {
returnnew Time(dateTimeFormat.parse(value));
}
@Override
public String getStringValue(Time time) {
return dateTimeFormat.format(time.getDate());
}
};
timeField.setPropertyEditor(propertyEditor);
// timeField.setFormat(dateTimeFormat);
}
});
viewport.add(horizontalPanel, new BorderLayoutData(LayoutRegion.CENTER));
RootPanel.get().add(viewport);
}
}
I just tested setFormat against GXT 2.2 beta 1 and GXT 2.1.3 and it works without any problems
andreiastra
23 Jul 2010, 5:02 AM
Hi Sven,
I ran the above example it with GXT 2.1.0. I tried it also with GXT 2.2.0. Again,
handleEvent(ButtonEvent be) {
...
timeField.setFormat(dateTimeFormat);
}
didn't do anything.
Can you please try my example? Am I missing something here?
Tested it on FF and IE8.
You cannot change the format after rendering, You need to create a new timefield
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.