use of org.adempiere.webui.util.SortComparator in project adempiere by adempiere.
the class GridTableListModel method sort.
/**
* 排序
* @param cmpr 比较类(支持两种比较类ListitemComparator、SortComparator)
* @param ascending 是否是升序
* @see ListModelExt#sort(Comparator, boolean)
*/
@SuppressWarnings("unchecked")
public void sort(Comparator cmpr, boolean ascending) {
//use default zk comparator
if (cmpr instanceof ListitemComparator) {
ListitemComparator lic = (ListitemComparator) cmpr;
tableModel.sort(lic.getListheader().getColumnIndex(), ascending);
} else if (cmpr instanceof SortComparator) {
SortComparator sc = (SortComparator) cmpr;
tableModel.sort(sc.getColumnIndex(), ascending);
}
fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1);
}
use of org.adempiere.webui.util.SortComparator in project adempiere by adempiere.
the class GridPanel method setupColumns.
private void setupColumns() {
if (init)
return;
Columns columns = new Columns();
// listbox.appendChild(columns); // moved to end
columns.setSizable(true);
columns.setMenupopup("auto");
columns.setColumnsgroup(false);
Map<Integer, String> colnames = new HashMap<Integer, String>();
int index = 0;
for (int i = 0; i < numColumns; i++) {
if (gridField[i].isDisplayed()) {
colnames.put(index, gridField[i].getHeader());
index++;
org.zkoss.zul.Column column = new Column();
column.setSortAscending(new SortComparator(i, true, Env.getLanguage(Env.getCtx())));
column.setSortDescending(new SortComparator(i, false, Env.getLanguage(Env.getCtx())));
column.setLabel(gridField[i].getHeader());
int displayLength = gridField[i].getPreferredWidthInListView() > 0 ? gridField[i].getPreferredWidthInListView() : gridField[i].getDisplayLength() * 9;
int l = DisplayType.isNumeric(gridField[i].getDisplayType()) ? 120 : displayLength;
if (gridField[i].getHeader().length() * 9 > l)
l = gridField[i].getHeader().length() * 9;
if (l > MAX_COLUMN_WIDTH)
l = MAX_COLUMN_WIDTH;
else if (l < MIN_COLUMN_WIDTH && gridField[i].getPreferredWidthInListView() <= 0)
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");
// FR 3051618 - Hide in list view
if (!gridField[i].isDisplayedGrid()) {
column.setVisible(false);
}
columns.appendChild(column);
listbox.appendChild(columns);
}
}
}
Aggregations