diff --git a/client/src/org/compiere/apps/APanel.java b/client/src/org/compiere/apps/APanel.java index e43fea2449..19321f86f4 100644 --- a/client/src/org/compiere/apps/APanel.java +++ b/client/src/org/compiere/apps/APanel.java @@ -29,8 +29,10 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.Properties; import java.util.Vector; import java.util.logging.Level; @@ -77,6 +79,7 @@ import org.compiere.model.GridTable; import org.compiere.model.GridWindow; import org.compiere.model.GridWindowVO; import org.compiere.model.GridWorkbench; +import org.compiere.model.Lookup; import org.compiere.model.MLookupFactory; import org.compiere.model.MProcess; import org.compiere.model.MQuery; @@ -1824,22 +1827,45 @@ public final class APanel extends CPanel Vector data = new Vector(); // FR [ 2877111 ] final String keyColumnName = m_curTab.getKeyColumnName(); - final String sql = MLookupFactory.getLookup_TableDirEmbed(Env.getLanguage(m_ctx), keyColumnName, "[?","?]") - .replace("[?.?]", "?"); + String sql = null; + if (! "".equals(keyColumnName)) { + sql = MLookupFactory.getLookup_TableDirEmbed(Env.getLanguage(m_ctx), keyColumnName, "[?","?]") + .replace("[?.?]", "?"); + } int noOfRows = m_curTab.getRowCount(); for(int i = 0; i < noOfRows; i++) { - final int id = m_curTab.getKeyID(i); StringBuffer displayValue = new StringBuffer(); - String value = DB.getSQLValueStringEx(null, sql, id); - value = value.replace(" - ", " | "); - displayValue.append(value); - // Append ID - if (displayValue.length() == 0 || CLogMgt.isLevelFine()) + if ("".equals(keyColumnName)) { - if (displayValue.length() > 0) - displayValue.append(" | "); - displayValue.append("<").append(id).append(">"); + ArrayList parentColumnNames = m_curTab.getParentColumnNames(); + for (Iterator iter = parentColumnNames.iterator(); iter.hasNext();) + { + String columnName = iter.next(); + GridField field = m_curTab.getField(columnName); + if(field.isLookup()){ + Lookup lookup = field.getLookup(); + if (lookup != null){ + displayValue = displayValue.append(lookup.getDisplay(m_curTab.getValue(i,columnName))).append(" | "); + } else { + displayValue = displayValue.append(m_curTab.getValue(i,columnName)).append(" | "); + } + } else { + displayValue = displayValue.append(m_curTab.getValue(i,columnName)).append(" | "); + } + } + } else { + final int id = m_curTab.getKeyID(i); + String value = DB.getSQLValueStringEx(null, sql, id); + value = value.replace(" - ", " | "); + displayValue.append(value); + // Append ID + if (displayValue.length() == 0 || CLogMgt.isLevelFine()) + { + if (displayValue.length() > 0) + displayValue.append(" | "); + displayValue.append("<").append(id).append(">"); + } } // data.add(displayValue.toString()); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java index fd2752568e..2f941aac8e 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java @@ -17,6 +17,7 @@ package org.adempiere.webui.panel; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; @@ -57,6 +58,7 @@ import org.compiere.model.GridTab; import org.compiere.model.GridTable; import org.compiere.model.GridWindow; import org.compiere.model.GridWindowVO; +import org.compiere.model.Lookup; import org.compiere.model.MLookupFactory; import org.compiere.model.MProcess; import org.compiere.model.MQuery; @@ -1400,22 +1402,45 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To Vector data = new Vector(); // FR [ 2877111 ] final String keyColumnName = curTab.getKeyColumnName(); - final String sql = MLookupFactory.getLookup_TableDirEmbed(Env.getLanguage(ctx), keyColumnName, "[?","?]") - .replace("[?.?]", "?"); + String sql = null; + if (! "".equals(keyColumnName)) { + sql = MLookupFactory.getLookup_TableDirEmbed(Env.getLanguage(ctx), keyColumnName, "[?","?]") + .replace("[?.?]", "?"); + } int noOfRows = curTab.getRowCount(); for(int i=0; i 0) - displayValue.append(" | "); - displayValue.append("<").append(id).append(">"); + ArrayList parentColumnNames = curTab.getParentColumnNames(); + for (Iterator iter = parentColumnNames.iterator(); iter.hasNext();) + { + String columnName = iter.next(); + GridField field = curTab.getField(columnName); + if(field.isLookup()){ + Lookup lookup = field.getLookup(); + if (lookup != null){ + displayValue = displayValue.append(lookup.getDisplay(curTab.getValue(i,columnName))).append(" | "); + } else { + displayValue = displayValue.append(curTab.getValue(i,columnName)).append(" | "); + } + } else { + displayValue = displayValue.append(curTab.getValue(i,columnName)).append(" | "); + } + } + } else { + final int id = curTab.getKeyID(i); + String value = DB.getSQLValueStringEx(null, sql, id); + value = value.replace(" - ", " | "); + displayValue.append(value); + // Append ID + if (displayValue.length() == 0 || CLogMgt.isLevelFine()) + { + if (displayValue.length() > 0) + displayValue.append(" | "); + displayValue.append("<").append(id).append(">"); + } } // data.add(displayValue.toString());