From 35d6fbc1b49fc029c62814d16f0e17d46e007041 Mon Sep 17 00:00:00 2001 From: hieplq Date: Wed, 6 Dec 2017 15:59:38 +0100 Subject: [PATCH] IDEMPIERE-2480:ZK7 - Horizontal Scrollbar calculate wrong full width --- .../adempiere/webui/adwindow/GridView.java | 10 +++-- org.adempiere.ui.zk/index.zul | 38 ++++++++++++++++++- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java index 936cdc4fe7..b9ca3e3c25 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java @@ -63,7 +63,7 @@ import org.zkoss.zul.Frozen; import org.zkoss.zul.Paging; import org.zkoss.zul.Row; import org.zkoss.zul.Tabpanel; -import org.zkoss.zul.Vbox; +import org.zkoss.zul.Vlayout; import org.zkoss.zul.event.ZulEvents; import org.zkoss.zul.impl.CustomGridDataLoader; @@ -72,8 +72,9 @@ import org.zkoss.zul.impl.CustomGridDataLoader; * @author Low Heng Sin * */ -public class GridView extends Vbox implements EventListener, IdSpace, IFieldEditorContainer, StateChangeListener +public class GridView extends Vlayout implements EventListener, IdSpace, IFieldEditorContainer, StateChangeListener { + /** * */ @@ -243,7 +244,10 @@ public class GridView extends Vbox implements EventListener, IdSpace, IFi setupColumns(); render(); - + if (listbox.getFrozen() != null){ + listbox.getFrozen().setWidgetOverride("syncScroll", "function (){syncScrollOVR(this);}"); + } + updateListIndex(); this.init = true; diff --git a/org.adempiere.ui.zk/index.zul b/org.adempiere.ui.zk/index.zul index 5a554a5bf4..5aa8ed4320 100644 --- a/org.adempiere.ui.zk/index.zul +++ b/org.adempiere.ui.zk/index.zul @@ -250,8 +250,44 @@ Copyright (C) 2007 Ashley G Ramdass. } this.$onSize.apply(this, arguments); }); - }); + }); + // overload for recalculate width of scroll when has frozen control + function syncScrollOVR (wgt){ + var parent = wgt.parent; + + if (parent.eheadtbl && parent._nativebar) { + var scroll = wgt.$n('scrollX'); + var cells = parent._getFirstRowCells(parent.eheadrows); + var totalcols = cells.length; + var columns = wgt._columns; + var scrollScale = totalcols - columns - 1; + var leftWidth = 0; + + var headerWidth = 0; + for (var i = 0; i < columns; i++) + headerWidth += cells[i].offsetWidth; + + var bodyWidth = parent.$n('body').offsetWidth; + var extraWidth = parent.$n('body').offsetWidth - headerWidth; + var extraColumnNum = 0; + for (var i = totalcols - 1; i >= columns; i--){ + extraWidth -= cells[i].offsetWidth; + if (cells[i].offsetWidth == 0)// when scroll to right, column at left has width = 0 + continue; + if (extraWidth >= 0){ + extraColumnNum++; + }else{ + break; + } + } + + + scroll.firstChild.style.width = jq.px0(bodyWidth + 50 * (scrollScale - extraColumnNum)); + } + + wgt.$syncScroll () + } ]]>