IDEMPIERE-2736:let WEditor decide component use for display value in gridView

This commit is contained in:
hieplq 2015-07-20 00:14:18 +07:00
parent 3edf4311ee
commit 8ac242da5b
3 changed files with 30 additions and 5 deletions

View File

@ -53,6 +53,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.Cell; import org.zkoss.zul.Cell;
import org.zkoss.zul.Grid; import org.zkoss.zul.Grid;
import org.zkoss.zul.Html;
import org.zkoss.zul.Label; import org.zkoss.zul.Label;
import org.zkoss.zul.Paging; import org.zkoss.zul.Paging;
import org.zkoss.zul.RendererCtrl; import org.zkoss.zul.RendererCtrl;
@ -236,11 +237,19 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
component = editor.getComponent(); component = editor.getComponent();
} else { } else {
String text = getDisplayText(value, gridField, rowIndex, isForceGetValue); String text = getDisplayText(value, gridField, rowIndex, isForceGetValue);
WEditor editor = getEditorCell(gridField);
Label label = new Label(); if (editor.getDisplayComponent() == null){
setLabelText(text, label); Label label = new Label();
setLabelText(text, label);
component = label; component = label;
}else{
component = editor.getDisplayComponent();
if (component instanceof Html){
((Html)component).setContent(text);
}else{
throw new UnsupportedOperationException("neet a componet has setvalue function");
}
}
} }
return component; return component;
} }
@ -316,6 +325,8 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
checkBox.setChecked(true); checkBox.setChecked(true);
else else
checkBox.setChecked(false); checkBox.setChecked(false);
} else if (component instanceof Html){
((Html)component).setContent(getDisplayText(entry.getValue().getValue(), entry.getValue().getGridField(), -1));
} }
} }
if (row == null) if (row == null)

View File

@ -687,6 +687,16 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
this.isProcessParameter = isProcessParameter; this.isProcessParameter = isProcessParameter;
} }
/**
* return component use for display value in grid view mode in non edit status
* if return null, a label will replace.
* because each row must has one instance of this component, don't cache it. just create new instance
* @return
*/
public Component getDisplayComponent() {
return null;
}
private static final String STYLE_ZOOMABLE_LABEL = "cursor: pointer; text-decoration: underline;"; private static final String STYLE_ZOOMABLE_LABEL = "cursor: pointer; text-decoration: underline;";
private static final String STYLE_NORMAL_LABEL = "color: #333;"; private static final String STYLE_NORMAL_LABEL = "color: #333;";
private static final String STYLE_EMPTY_MANDATORY_LABEL = "color: red;"; private static final String STYLE_EMPTY_MANDATORY_LABEL = "color: red;";

View File

@ -13,6 +13,10 @@ html,body {
overflow: hidden; overflow: hidden;
} }
.z-html p{
margin:0px;
}
<%-- Tablet --%> <%-- Tablet --%>
.tablet-scrolling { .tablet-scrolling {
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;