View Full Version : TimeField Question
TheBuzzer
1 Oct 2008, 3:30 PM
How am i suppose to set a time as a default value?
I realized I have this with all combo box.
I want it to have a default value so I did setRawValue("1:00 AM");
But when i open the section. the value does not get set. It is still blank.
TheBuzzer
1 Oct 2008, 4:56 PM
Well I realized I got to use setValue but I had to make a BaseModelData with a field text so I did this helper class maybe it will be added into TimeField
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.ottoos.client.Forms.OrderInformation;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.widget.form.TimeField;
import java.util.Date;
/**
*
* @author dlee
*/
public class FixTimeField extends TimeField {
public Date getTime() {
if (getForceSelection()) {
doForce();
}
if (getValue() == null) {
try {
return getFormat().parse(getRawValue());
} catch (IllegalArgumentException e) {
return null;
}
} else {
return getFormat().parse((String) getValue().get("text"));
}
}
public void setTime(Date time) {
if (time != null) {
BaseModelData thetime = new BaseModelData();
thetime.set("text", getFormat().format(time));
setValue(thetime);
}
}
@Override
protected void onBlur(final ComponentEvent ce) {
super.onBlur(ce);
if (getForceSelection()) {
doForce();
}
if (getValue() == null) {
fireChangeEvent(focusValue, getRawValue());
} else {
fireChangeEvent(focusValue, getValue());
}
}
}
This way the timefield can getTime and setTime
TheBuzzer
1 Oct 2008, 4:59 PM
this seem to have a bit of a problem still though in getting user inputted time and not from the list.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.