r8413, hengsin, 2009-02-11

Log Message:
-----------
[ 2587959 ] Grid always refresh even when not visible
[ 2587964 ] Grid create new mlookup for each row
This commit is contained in:
Heng Sin Low 2009-02-11 08:19:49 +00:00
parent 19b251fecb
commit 34a5b37c55
1 changed files with 7 additions and 18 deletions

View File

@ -31,12 +31,9 @@ import org.adempiere.webui.util.GridTabDataBinder;
import org.adempiere.webui.window.ADWindow; import org.adempiere.webui.window.ADWindow;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.MAccountLookup;
import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.NamePair; import org.compiere.util.NamePair;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
@ -77,6 +74,11 @@ public class GridTabListItemRenderer implements ListitemRenderer, ListitemRender
* @see ListitemRenderer#render(Listitem, Object) * @see ListitemRenderer#render(Listitem, Object)
*/ */
public void render(Listitem listitem, Object data) throws Exception { public void render(Listitem listitem, Object data) throws Exception {
//don't render if not visible
for(Component c = listitem.getParent(); c != null; c = c.getParent()) {
if (!c.isVisible())
return;
}
Object[] values = (Object[])data; Object[] values = (Object[])data;
int columnCount = gridTab.getTableModel().getColumnCount(); int columnCount = gridTab.getTableModel().getColumnCount();
GridField[] gridField = gridTab.getFields(); GridField[] gridField = gridTab.getFields();
@ -238,20 +240,7 @@ public class GridTabListItemRenderer implements ListitemRenderer, ListitemRender
GridField[] gridField = gridTab.getFields(); GridField[] gridField = gridTab.getFields();
if (gridField[columnIndex].isLookup()) if (gridField[columnIndex].isLookup())
{ {
NamePair namepair = null; NamePair namepair = gridField[columnIndex].getLookup().get(value);
if (gridField[columnIndex].getDisplayType() == DisplayType.Account)
{
MAccountLookup lookup = new MAccountLookup(Env.getCtx(), windowNo);
namepair = lookup.get(value);
}
else
{
MLookup lookup = MLookupFactory.get(
Env.getCtx(), windowNo, 0, gridField[columnIndex].getAD_Column_ID(),
gridField[columnIndex].getDisplayType());
namepair = lookup.get(value);
}
if (namepair != null) if (namepair != null)
return namepair.getName(); return namepair.getName();
else else