diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java index e3d4afc727..76e1a38b64 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java @@ -861,4 +861,22 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt Events.sendEvent(gridPanel, new Event("onSelectRow", gridPanel, checkBox)); } } + + /** + * Check if the new value in the field, changes the display logic in the dependant fields + * @param dependantFields + */ + public void checkDependants(ArrayList dependantFields){ + + for ( GridField field : dependantFields ){ + + WEditor editor = editors.get(field); + boolean isEditable = field.isEditableGrid(true); + editor.setReadWrite(isEditable); + if( isEditable ) + gridPanel.refresh(gridTab); + } + + } + } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/util/GridTabDataBinder.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/util/GridTabDataBinder.java index 19a2a6b905..d7bbe12b78 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/util/GridTabDataBinder.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/util/GridTabDataBinder.java @@ -12,11 +12,14 @@ *****************************************************************************/ package org.adempiere.webui.util; +import java.util.ArrayList; import java.util.Properties; import java.util.logging.Level; import org.adempiere.base.Core; import org.adempiere.exceptions.AdempiereException; +import org.adempiere.webui.adwindow.GridTabRowRenderer; +import org.adempiere.webui.component.Grid; import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeListener; @@ -26,6 +29,7 @@ import org.compiere.model.GridTable; import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Trx; +import org.zkoss.zul.RowRenderer; /** * Transfer data from editor to GridTab @@ -165,6 +169,28 @@ public class GridTabDataBinder implements ValueChangeListener { } } } + + //Checks if the change in a field modifies the display logic in the dependant fields + Object source = e.getSource(); + WEditor editor = (WEditor) source; + + if( editor != null ){ + + ArrayList dependants = gridTab.getDependantFields(editor.getColumnName()); + + if ( dependants != null && !dependants.isEmpty() ) + if( editor.getComponent() != null ) //Editor + if( editor.getComponent().getParent() != null) //Cell + if( editor.getComponent().getParent().getParent() != null ) //Row + if( editor.getComponent().getParent().getParent().getParent() != null ) //Rows + if( editor.getComponent().getParent().getParent().getParent().getParent() != null ){ //Grid + Grid listBox = (Grid) editor.getComponent().getParent().getParent().getParent().getParent(); + RowRenderer renderer = listBox.getRowRenderer(); + GridTabRowRenderer gtr = (GridTabRowRenderer)renderer; + gtr.checkDependants(dependants); + + } + } } // ValueChange