From 7b0ce20cb86980648c3da9af84969ae8877e9738 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 9 Aug 2016 17:21:55 +0800 Subject: [PATCH] 1006181 Speed-up windows - Field to show read-only grid. Fixed sorting. (IDEMPIERE-3269) --- .../grid/selection/GridTabSelectionListView.java | 10 ++++++++++ .../grid/selection/SimpleGridTableListModel.java | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/grid/selection/GridTabSelectionListView.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/grid/selection/GridTabSelectionListView.java index 10acb8888a..33dee3488c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/grid/selection/GridTabSelectionListView.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/grid/selection/GridTabSelectionListView.java @@ -237,6 +237,7 @@ public class GridTabSelectionListView extends Borderlayout ListHeader colHeader = new ListHeader(); colHeader.setSort("auto"); colHeader.setLabel(gridField[i].getHeader()); + colHeader.setAttribute("ColumnIndex", getColumnIndex(gridField[i].getColumnName())); if (columnWidthMap != null && columnWidthMap.get(gridField[i].getAD_Field_ID()) != null) { colHeader.setWidth(columnWidthMap.get(gridField[i].getAD_Field_ID())); } else { @@ -256,6 +257,15 @@ public class GridTabSelectionListView extends Borderlayout listbox.appendChild(header); } + private int getColumnIndex(String columnName) { + for(int i = 0; i < gridTab.getTableModel().getColumnCount(); i++) { + if (gridTab.getTableModel().getColumnName(i).equals(columnName)) { + return i; + } + } + return -1; + } + private void render() { listbox.setStyle("min-height: 200px"); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/grid/selection/SimpleGridTableListModel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/grid/selection/SimpleGridTableListModel.java index 41f4f45288..7cdb06941d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/grid/selection/SimpleGridTableListModel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/grid/selection/SimpleGridTableListModel.java @@ -113,7 +113,11 @@ public class SimpleGridTableListModel extends AbstractListModel im //use default zk comparator if (cmpr instanceof ListitemComparator) { ListitemComparator lic = (ListitemComparator) cmpr; - tableModel.sort(lic.getListheader().getColumnIndex(), ascending); + Integer index = (Integer) lic.getListheader().getAttribute("ColumnIndex"); + if (index != null && index.intValue() >= 0) + tableModel.sort(index.intValue(), ascending); + else + tableModel.sort(lic.getListheader().getColumnIndex(), ascending); } else if (cmpr instanceof SortComparator) { SortComparator sc = (SortComparator)cmpr; tableModel.sort(sc.getColumnIndex(), ascending);