summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2015-07-09 14:51:30 +0300
committerVaadin Code Review <review@vaadin.com>2015-07-15 08:41:20 +0000
commit0f9d0b0bf1cd5fb58f47f22bd6d52a9fac31c530 (patch)
tree3ae873db1d7e67aba0c0a585169ce152ae34a6dd /client
parent3b05685493d17e89404025e3cdd81d47e511b0ce (diff)
downloadvaadin-framework-0f9d0b0bf1cd5fb58f47f22bd6d52a9fac31c530.tar.gz
vaadin-framework-0f9d0b0bf1cd5fb58f47f22bd6d52a9fac31c530.zip
Support frozen columns in Grid editor (#16727)
Change-Id: Iff797c3bf90a6021099a3ed4082cfca3a6fb3540
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java43
1 files changed, 36 insertions, 7 deletions
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index 58fc532a77..232d67c1d4 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -1135,6 +1135,8 @@ public class Grid<T> extends ResizeComposite implements
private DivElement editorOverlay = DivElement.as(DOM.createDiv());
private DivElement cellWrapper = DivElement.as(DOM.createDiv());
+ private DivElement frozenCellWrapper = DivElement.as(DOM.createDiv());
+
private DivElement messageAndButtonsWrapper = DivElement.as(DOM
.createDiv());
@@ -1530,15 +1532,31 @@ public class Grid<T> extends ResizeComposite implements
});
gridElement.appendChild(editorOverlay);
+ editorOverlay.appendChild(frozenCellWrapper);
editorOverlay.appendChild(cellWrapper);
editorOverlay.appendChild(messageAndButtonsWrapper);
+ int frozenColumns = grid.getVisibleFrozenColumnCount();
+ double frozenColumnsWidth = 0;
+ double cellHeight = 0;
+
for (int i = 0; i < tr.getCells().getLength(); i++) {
Element cell = createCell(tr.getCells().getItem(i));
-
- cellWrapper.appendChild(cell);
+ cellHeight = Math.max(cellHeight, WidgetUtil
+ .getRequiredHeightBoundingClientRectDouble(tr
+ .getCells().getItem(i)));
Column<?, T> column = grid.getVisibleColumn(i);
+
+ if (i < frozenColumns) {
+ frozenCellWrapper.appendChild(cell);
+ frozenColumnsWidth += WidgetUtil
+ .getRequiredWidthBoundingClientRectDouble(tr
+ .getCells().getItem(i));
+ } else {
+ cellWrapper.appendChild(cell);
+ }
+
if (column.isEditable()) {
Widget editor = getHandler().getWidget(column);
@@ -1560,6 +1578,10 @@ public class Grid<T> extends ResizeComposite implements
}
}
+ setBounds(frozenCellWrapper, 0, 0, frozenColumnsWidth, 0);
+ setBounds(cellWrapper, frozenColumnsWidth, 0, tr.getOffsetWidth()
+ - frozenColumnsWidth, cellHeight);
+
// Only add these elements once
if (!messageAndButtonsWrapper.isOrHasChild(messageWrapper)) {
messageAndButtonsWrapper.appendChild(messageWrapper);
@@ -1624,6 +1646,7 @@ public class Grid<T> extends ResizeComposite implements
editorOverlay.removeAllChildren();
cellWrapper.removeAllChildren();
+ frozenCellWrapper.removeAllChildren();
editorOverlay.removeFromParent();
scrollHandler.removeHandler();
@@ -1636,6 +1659,7 @@ public class Grid<T> extends ResizeComposite implements
editorOverlay.removeClassName(styleName);
cellWrapper.removeClassName(styleName + "-cells");
+ frozenCellWrapper.removeClassName(styleName + "-cells");
messageAndButtonsWrapper.removeClassName(styleName + "-footer");
messageWrapper.removeClassName(styleName + "-message");
@@ -1648,6 +1672,7 @@ public class Grid<T> extends ResizeComposite implements
editorOverlay.setClassName(styleName);
cellWrapper.setClassName(styleName + "-cells");
+ frozenCellWrapper.setClassName(styleName + "-cells frozen");
messageAndButtonsWrapper.setClassName(styleName + "-footer");
messageWrapper.setClassName(styleName + "-message");
@@ -1698,7 +1723,8 @@ public class Grid<T> extends ResizeComposite implements
private void updateHorizontalScrollPosition() {
double scrollLeft = grid.getScrollLeft();
- cellWrapper.getStyle().setLeft(-scrollLeft, Unit.PX);
+ cellWrapper.getStyle().setLeft(
+ frozenCellWrapper.getOffsetWidth() - scrollLeft, Unit.PX);
}
protected void setGridEnabled(boolean enabled) {
@@ -6051,7 +6077,12 @@ public class Grid<T> extends ResizeComposite implements
}
private void updateFrozenColumns() {
- int numberOfColumns = frozenColumnCount;
+ escalator.getColumnConfiguration().setFrozenColumnCount(
+ getVisibleFrozenColumnCount());
+ }
+
+ private int getVisibleFrozenColumnCount() {
+ int numberOfColumns = getFrozenColumnCount();
// for the escalator the hidden columns are not in the frozen column
// count, but for grid they are. thus need to convert the index
@@ -6066,9 +6097,7 @@ public class Grid<T> extends ResizeComposite implements
} else if (selectionColumn != null) {
numberOfColumns++;
}
-
- escalator.getColumnConfiguration()
- .setFrozenColumnCount(numberOfColumns);
+ return numberOfColumns;
}
/**