Fixed a field editor focus bug, better column width for "Line" column and better IE8 support.

This commit is contained in:
Heng Sin Low 2010-09-13 23:42:34 +08:00
parent 2e8c23cd80
commit 7d17e9719c
1 changed files with 29 additions and 14 deletions

View File

@ -272,21 +272,29 @@ public class GridPanel extends Borderlayout implements EventListener
column.setLabel(gridField[i].getHeader()); column.setLabel(gridField[i].getHeader());
int l = DisplayType.isNumeric(gridField[i].getDisplayType()) int l = DisplayType.isNumeric(gridField[i].getDisplayType())
? 120 : gridField[i].getDisplayLength() * 9; ? 120 : gridField[i].getDisplayLength() * 9;
if (gridField[i].getHeader().length() * 9 > l) //special treatment for line
l = gridField[i].getHeader().length() * 9; if (DisplayType.isNumeric(gridField[i].getDisplayType()) && "Line".equals(gridField[i].getColumnName()))
if (l > MAX_COLUMN_WIDTH)
l = MAX_COLUMN_WIDTH;
else if ( l < MIN_COLUMN_WIDTH)
l = MIN_COLUMN_WIDTH;
if (gridField[i].getDisplayType() == DisplayType.Table || gridField[i].getDisplayType() == DisplayType.TableDir)
{ {
if (l < MIN_COMBOBOX_WIDTH) l = 60;
l = MIN_COMBOBOX_WIDTH;
} }
else if (DisplayType.isNumeric(gridField[i].getDisplayType())) else
{ {
if (l < MIN_NUMERIC_COL_WIDTH) if (gridField[i].getHeader().length() * 9 > l)
l = MIN_NUMERIC_COL_WIDTH; l = gridField[i].getHeader().length() * 9;
if (l > MAX_COLUMN_WIDTH)
l = MAX_COLUMN_WIDTH;
else if ( l < MIN_COLUMN_WIDTH)
l = MIN_COLUMN_WIDTH;
if (gridField[i].getDisplayType() == DisplayType.Table || gridField[i].getDisplayType() == DisplayType.TableDir)
{
if (l < MIN_COMBOBOX_WIDTH)
l = MIN_COMBOBOX_WIDTH;
}
else if (DisplayType.isNumeric(gridField[i].getDisplayType()))
{
if (l < MIN_NUMERIC_COL_WIDTH)
l = MIN_NUMERIC_COL_WIDTH;
}
} }
column.setWidth(Integer.toString(l) + "px"); column.setWidth(Integer.toString(l) + "px");
columns.appendChild(column); columns.appendChild(column);
@ -299,7 +307,8 @@ public class GridPanel extends Borderlayout implements EventListener
LayoutUtils.addSclass("adtab-grid-panel", this); LayoutUtils.addSclass("adtab-grid-panel", this);
listbox.setVflex(true); listbox.setVflex(true);
listbox.setFixedLayout(true); //true is faster but render badly on some browser
listbox.setFixedLayout(false);
listbox.addEventListener(Events.ON_CLICK, this); listbox.addEventListener(Events.ON_CLICK, this);
updateModel(); updateModel();
@ -634,7 +643,13 @@ public class GridPanel extends Borderlayout implements EventListener
editor.setHasFocus(false); editor.setHasFocus(false);
else if (columnName.equals(editor.getColumnName())) { else if (columnName.equals(editor.getColumnName())) {
editor.setHasFocus(true); editor.setHasFocus(true);
Clients.response(new AuFocus(editor.getComponent())); Component c = editor.getComponent();
if (c instanceof EditorBox) {
c = ((EditorBox)c).getTextbox();
} else if (c instanceof NumberBox) {
c = ((NumberBox)c).getDecimalbox();
}
Clients.response(new AuFocus(c));
found = true; found = true;
} }
} }