【发布时间】:2014-05-05 07:26:39
【问题描述】:
我使用 GXT 2.2.3 创建了一个 EditorGrid。在该网格中,一列以 TextField 作为编辑器。我的代码如下:
ColumnConfig checkinTimecolumn=new ColumnConfig();
checkinTimecolumn.setId("checkinTime");
checkinTimecolumn.setHeader("Check In Time");
checkinTimecolumn.setWidth(80);
checkinTimecolumn.setMenuDisabled(true);
checkinTimecolumn.setSortable(false);
checkinTimecolumn.setStyle("width:100%;");
checkinTimecolumn.setStyle("padding-right:3px;");
final TextField<String> checkintime = new TextField<String>();
checkintime.setAllowBlank(true);
checkintime.setWidth(15);
checkintime.addListener(Events.Change, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
String prevcheckIntime=ACCCheckBoxModel.getSelectedItem().getCheckinTime();
String variable = checkintime.getRawValue().trim();
// Window.alert("Getting the previous time-->"+prevcheckIntime);
if(variable != null & !variable.equalsIgnoreCase(""))
{
if(!variable.matches(REG_EXP))
{
if(prevcheckIntime!=null){
checkintime.setValue(prevcheckIntime);
setDuration(ACCCheckBoxModel.getSelectedItem().getCheckinDate(),
checkintime.getRawValue(),
ACCCheckBoxModel.getSelectedItem().getCheckoutDate(),ACCCheckBoxModel.getSelectedItem().getCheckoutTime());
}
else {
checkintime.clear();
setDuration(ACCCheckBoxModel.getSelectedItem().getCheckinDate(),
null,
ACCCheckBoxModel.getSelectedItem().getCheckoutDate(), ACCCheckBoxModel.getSelectedItem().getCheckoutTime());
}
MsgBox.info("Enter time in hh:mm format");
checkintime.focus();
return;
}
String [] a=variable.split(":");
if(Integer.parseInt(a[0])>24) {
if(prevcheckIntime!=null){
checkintime.setValue(prevcheckIntime);
setDuration(ACCCheckBoxModel.getSelectedItem().getCheckinDate(),
checkintime.getRawValue(),
ACCCheckBoxModel.getSelectedItem().getCheckoutDate(), ACCCheckBoxModel.getSelectedItem().getCheckoutTime());
}
else {
checkintime.clear();
setDuration(ACCCheckBoxModel.getSelectedItem().getCheckinDate(),
null,
ACCCheckBoxModel.getSelectedItem().getCheckoutDate(), ACCCheckBoxModel.getSelectedItem().getCheckoutTime());
}
MsgBox.info(variable+" is not a valid time. 00:00 to 23:59 are valid" );
checkintime.focus();
return;
}
else{
setDuration(ACCCheckBoxModel.getSelectedItem().getCheckinDate(),
checkintime.getRawValue(),
ACCCheckBoxModel.getSelectedItem().getCheckoutDate(), ACCCheckBoxModel.getSelectedItem().getCheckoutTime());
}
}
else {
setDuration(ACCCheckBoxModel.getSelectedItem().getCheckinDate(),
null,
ACCCheckBoxModel.getSelectedItem().getCheckoutDate(), ACCCheckBoxModel.getSelectedItem().getCheckoutTime());
}
}
});
checkinTimecolumn.setRenderer(checkinRenderer);
checkinTimecolumn.setEditor(new CellEditor(checkintime));
checkinTimecolumn.setAlignment(HorizontalAlignment.LEFT);
configs.add(checkinTimecolumn);
现在的问题是,如果单击 CheckInTime 列中的 checkIntime 字段后,如果我单击 Gird 中的其他位置,则焦点不会出现。此问题仅在 Chrome 中发生。在 IE 中运行良好和 Firefox。
请建议如何解决这个问题。
更新
如果用鼠标单击行以外的行,则无法从 TextField 中获得焦点,这就是问题,并且 Tab 键也无法在此 Grid 上工作。
我为正确对齐行和列而设置的 Css 在 IE 中运行良好,但在 Chrome 和 Firefox 中运行不正常
【问题讨论】:
-
请任何人对此作出回应。
-
使用
checkinTimecolumn.setStyle("width:100%;padding-right:3px;");而不是多个setStyle()方法调用。 -
@Braj 我明天会试试这个,让你知道
-
请分享最少的可编译可测试代码来分析它。
标签: java google-chrome gwt gxt