Performance: use simple row focus indicator and fixed layout.

This commit is contained in:
Heng Sin Low 2012-03-05 12:53:24 +08:00
parent 33fd4e4ae3
commit 877d0409ba
1 changed files with 23 additions and 5 deletions

View File

@ -39,6 +39,7 @@ import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients; import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Borderlayout; import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center; import org.zkoss.zul.Center;
import org.zkoss.zul.Frozen;
import org.zkoss.zul.South; import org.zkoss.zul.South;
import org.zkoss.zul.Column; import org.zkoss.zul.Column;
import org.zkoss.zul.Div; import org.zkoss.zul.Div;
@ -89,12 +90,14 @@ public class GridPanel extends Borderlayout implements EventListener
private South south; private South south;
private boolean modeless; private boolean modeless = true;
private String columnOnClick; private String columnOnClick;
private AbstractADWindowPanel windowPanel; private AbstractADWindowPanel windowPanel;
private boolean refreshing;
public static final String PAGE_SIZE_KEY = "ZK_PAGING_SIZE"; public static final String PAGE_SIZE_KEY = "ZK_PAGING_SIZE";
public static final String MODE_LESS_KEY = "ZK_GRID_EDIT_MODELESS"; public static final String MODE_LESS_KEY = "ZK_GRID_EDIT_MODELESS";
@ -118,8 +121,8 @@ public class GridPanel extends Borderlayout implements EventListener
//default paging size //default paging size
pageSize = MSysConfig.getIntValue(PAGE_SIZE_KEY, 100); pageSize = MSysConfig.getIntValue(PAGE_SIZE_KEY, 100);
//default false for better performance //default true for better UI experience
modeless = MSysConfig.getBooleanValue(MODE_LESS_KEY, false); modeless = MSysConfig.getBooleanValue(MODE_LESS_KEY, true);
} }
/** /**
@ -175,11 +178,17 @@ public class GridPanel extends Borderlayout implements EventListener
} }
else else
{ {
refreshing = true;
listbox.setModel(listModel); listbox.setModel(listModel);
updateListIndex(); updateListIndex();
refreshing = false;
} }
} }
public boolean isRefreshing() {
return refreshing;
}
/** /**
* Update current row from model * Update current row from model
*/ */
@ -253,6 +262,14 @@ public class GridPanel extends Borderlayout implements EventListener
if (init) return; if (init) return;
Columns columns = new Columns(); Columns columns = new Columns();
Frozen frozen = new Frozen();
frozen.setColumns(1);
listbox.appendChild(frozen);
org.zkoss.zul.Column indicator = new Column();
indicator.setWidth("30px");
columns.appendChild(indicator);
listbox.appendChild(columns); listbox.appendChild(columns);
columns.setSizable(true); columns.setSizable(true);
columns.setMenupopup("auto"); columns.setMenupopup("auto");
@ -307,8 +324,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);
//true is faster but render badly on some browser //true might looks better, false for better performance
listbox.setFixedLayout(false); listbox.setSizedByContent(false);
listbox.addEventListener(Events.ON_CLICK, this); listbox.addEventListener(Events.ON_CLICK, this);
updateModel(); updateModel();
@ -401,6 +418,7 @@ public class GridPanel extends Borderlayout implements EventListener
} }
} }
} }
event.stopPropagation();
} }
else if (event.getTarget() == paging) else if (event.getTarget() == paging)
{ {