IDEMPIERE-2480:ZK7 - Horizontal Scrollbar calculate wrong full width

This commit is contained in:
hieplq 2017-12-06 15:59:38 +01:00
parent 74cd2d1078
commit 35d6fbc1b4
2 changed files with 44 additions and 4 deletions

View File

@ -63,7 +63,7 @@ import org.zkoss.zul.Frozen;
import org.zkoss.zul.Paging; import org.zkoss.zul.Paging;
import org.zkoss.zul.Row; import org.zkoss.zul.Row;
import org.zkoss.zul.Tabpanel; 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.event.ZulEvents;
import org.zkoss.zul.impl.CustomGridDataLoader; import org.zkoss.zul.impl.CustomGridDataLoader;
@ -72,8 +72,9 @@ import org.zkoss.zul.impl.CustomGridDataLoader;
* @author Low Heng Sin * @author Low Heng Sin
* *
*/ */
public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFieldEditorContainer, StateChangeListener public class GridView extends Vlayout implements EventListener<Event>, IdSpace, IFieldEditorContainer, StateChangeListener
{ {
/** /**
* *
*/ */
@ -243,6 +244,9 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
setupColumns(); setupColumns();
render(); render();
if (listbox.getFrozen() != null){
listbox.getFrozen().setWidgetOverride("syncScroll", "function (){syncScrollOVR(this);}");
}
updateListIndex(); updateListIndex();

View File

@ -252,6 +252,42 @@ Copyright (C) 2007 Ashley G Ramdass.
}); });
}); });
// 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 ()
}
]]> ]]>
</script> </script>
<include src="${themePreference}"/> <include src="${themePreference}"/>