IDEMPIERE-1279 Grid column is often having default width that's too big.
This commit is contained in:
parent
9528b69977
commit
e679738649
|
@ -82,7 +82,7 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
|
||||||
|
|
||||||
private static final int MIN_COMBOBOX_WIDTH = 160;
|
private static final int MIN_COMBOBOX_WIDTH = 160;
|
||||||
|
|
||||||
private static final int MIN_NUMERIC_COL_WIDTH = 130;
|
private static final int MIN_NUMERIC_COL_WIDTH = 120;
|
||||||
|
|
||||||
private static final String ATTR_ON_POST_SELECTED_ROW_CHANGED = "org.adempiere.webui.adwindow.GridView.onPostSelectedRowChanged";
|
private static final String ATTR_ON_POST_SELECTED_ROW_CHANGED = "org.adempiere.webui.adwindow.GridView.onPostSelectedRowChanged";
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
|
||||||
protected void createListbox() {
|
protected void createListbox() {
|
||||||
listbox = new Grid();
|
listbox = new Grid();
|
||||||
listbox.setEmptyMessage(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "FindZeroRecords")));
|
listbox.setEmptyMessage(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "FindZeroRecords")));
|
||||||
listbox.setSizedByContent(true);
|
listbox.setSizedByContent(false);
|
||||||
listbox.setVflex("1");
|
listbox.setVflex("1");
|
||||||
listbox.setHflex("1");
|
listbox.setHflex("1");
|
||||||
listbox.setSclass("adtab-grid");
|
listbox.setSclass("adtab-grid");
|
||||||
|
@ -296,7 +296,7 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
|
||||||
refreshing = true;
|
refreshing = true;
|
||||||
listbox.setModel(listModel);
|
listbox.setModel(listModel);
|
||||||
updateListIndex();
|
updateListIndex();
|
||||||
refreshing = false;
|
refreshing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,34 +424,53 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
|
||||||
if (columnWidthMap != null && columnWidthMap.get(gridField[i].getAD_Field_ID()) != null) {
|
if (columnWidthMap != null && columnWidthMap.get(gridField[i].getAD_Field_ID()) != null) {
|
||||||
column.setWidth(columnWidthMap.get(gridField[i].getAD_Field_ID()));
|
column.setWidth(columnWidthMap.get(gridField[i].getAD_Field_ID()));
|
||||||
} else {
|
} else {
|
||||||
int l = DisplayType.isNumeric(gridField[i].getDisplayType())
|
if (gridField[i].getDisplayType()==DisplayType.YesNo) {
|
||||||
? 120 : gridField[i].getDisplayLength() * 9;
|
//safe to use minimum width for checkbox
|
||||||
//special treatment for line
|
column.setHflex("min");
|
||||||
if (DisplayType.isNumeric(gridField[i].getDisplayType()) && "Line".equals(gridField[i].getColumnName()))
|
} else if (DisplayType.isNumeric(gridField[i].getDisplayType()) && "Line".equals(gridField[i].getColumnName())) {
|
||||||
{
|
//special treatment for line
|
||||||
l = 60;
|
column.setHflex("min");
|
||||||
}
|
} else {
|
||||||
else
|
int estimatedWidth = 0;
|
||||||
{
|
if (DisplayType.isNumeric(gridField[i].getDisplayType()))
|
||||||
if (gridField[i].getHeader().length() * 9 > l)
|
estimatedWidth = MIN_NUMERIC_COL_WIDTH;
|
||||||
l = gridField[i].getHeader().length() * 9;
|
else if (DisplayType.isLookup(gridField[i].getDisplayType()))
|
||||||
if (l > MAX_COLUMN_WIDTH)
|
estimatedWidth = MIN_COMBOBOX_WIDTH;
|
||||||
l = MAX_COLUMN_WIDTH;
|
else if (DisplayType.isText(gridField[i].getDisplayType()))
|
||||||
else if ( l < MIN_COLUMN_WIDTH)
|
estimatedWidth = gridField[i].getDisplayLength() * 8;
|
||||||
l = MIN_COLUMN_WIDTH;
|
else
|
||||||
if (gridField[i].getDisplayType() == DisplayType.Table || gridField[i].getDisplayType() == DisplayType.TableDir)
|
estimatedWidth = MIN_COLUMN_WIDTH;
|
||||||
|
|
||||||
|
int headerWidth = (gridField[i].getHeader().length()+2) * 8;
|
||||||
|
if (headerWidth > estimatedWidth)
|
||||||
|
estimatedWidth = headerWidth;
|
||||||
|
|
||||||
|
if (DisplayType.isLookup(gridField[i].getDisplayType()))
|
||||||
{
|
{
|
||||||
if (l < MIN_COMBOBOX_WIDTH)
|
if (headerWidth > MIN_COMBOBOX_WIDTH)
|
||||||
l = MIN_COMBOBOX_WIDTH;
|
column.setHflex("min");
|
||||||
}
|
}
|
||||||
else if (DisplayType.isNumeric(gridField[i].getDisplayType()))
|
else if (DisplayType.isNumeric(gridField[i].getDisplayType()))
|
||||||
{
|
{
|
||||||
if (l < MIN_NUMERIC_COL_WIDTH)
|
if (headerWidth > MIN_NUMERIC_COL_WIDTH)
|
||||||
l = MIN_NUMERIC_COL_WIDTH;
|
column.setHflex("min");
|
||||||
|
}
|
||||||
|
else if (!DisplayType.isText(gridField[i].getDisplayType()))
|
||||||
|
{
|
||||||
|
if (headerWidth > MIN_COLUMN_WIDTH)
|
||||||
|
column.setHflex("min");
|
||||||
|
}
|
||||||
|
|
||||||
|
//set estimated width if not using hflex=min
|
||||||
|
if (!"min".equals(column.getHflex())) {
|
||||||
|
if (estimatedWidth > MAX_COLUMN_WIDTH)
|
||||||
|
estimatedWidth = MAX_COLUMN_WIDTH;
|
||||||
|
else if ( estimatedWidth < MIN_COLUMN_WIDTH)
|
||||||
|
estimatedWidth = MIN_COLUMN_WIDTH;
|
||||||
|
column.setWidth(Integer.toString(estimatedWidth) + "px");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
column.setWidth(Integer.toString(l) + "px");
|
}
|
||||||
}
|
|
||||||
columns.appendChild(column);
|
columns.appendChild(column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue