summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@gmail.com>2017-03-22 08:37:57 +0200
committerPekka Hyvönen <pekka@vaadin.com>2017-03-22 08:37:57 +0200
commitec0b52a1b6c506a184121c303adb5e4e4711b8f3 (patch)
treebe16606675a9a35d463aede24aea728e4d4c7ff1
parent9a679b57d13cce81dab5d6283767adba83e8c735 (diff)
downloadvaadin-framework-ec0b52a1b6c506a184121c303adb5e4e4711b8f3.tar.gz
vaadin-framework-ec0b52a1b6c506a184121c303adb5e4e4711b8f3.zip
Optimize grid by avoiding redundant row refreshes (#8874)
* Optimize grid by avoiding redundant row refreshes * Delay more calls to refreshBody()
-rwxr-xr-xclient/src/main/java/com/vaadin/client/widgets/Grid.java27
1 files changed, 21 insertions, 6 deletions
diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java
index 0b0642668f..50616c7930 100755
--- a/client/src/main/java/com/vaadin/client/widgets/Grid.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java
@@ -4181,6 +4181,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private RendererCellReference rendererCellReference = new RendererCellReference(
(RowReference<Object>) rowReference);
+ private boolean refreshBodyRequested = false;
+
private DragAndDropHandler.DragAndDropCallback headerCellDndCallback = new DragAndDropCallback() {
private final AutoScrollerCallback autoScrollerCallback = new AutoScrollerCallback() {
@@ -4907,7 +4909,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
}
if (grid != null) {
- grid.refreshBody();
+ grid.requestRefreshBody();
}
}
return this;
@@ -6200,7 +6202,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
if (isAttached()) {
refreshHeader();
- refreshBody();
+ requestRefreshBody();
refreshFooter();
}
}
@@ -6314,6 +6316,19 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
}
/**
+ * Request delayed refresh of all body rows.
+ */
+ private void requestRefreshBody() {
+ if (!refreshBodyRequested) {
+ refreshBodyRequested = true;
+ Scheduler.get().scheduleFinally(() -> {
+ refreshBodyRequested = false;
+ refreshBody();
+ });
+ }
+ }
+
+ /**
* Refreshes all footer rows
*/
void refreshFooter() {
@@ -7812,7 +7827,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
selectionColumn.initDone();
} else {
selectionColumn = null;
- refreshBody();
+ requestRefreshBody();
}
updateFrozenColumns();
@@ -7842,7 +7857,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
}
// Refresh rendered rows to update selection, if it has changed
- refreshBody();
+ requestRefreshBody();
}
/**
@@ -8510,7 +8525,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
public void setCellStyleGenerator(
CellStyleGenerator<T> cellStyleGenerator) {
this.cellStyleGenerator = cellStyleGenerator;
- refreshBody();
+ requestRefreshBody();
}
/**
@@ -8532,7 +8547,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
*/
public void setRowStyleGenerator(RowStyleGenerator<T> rowStyleGenerator) {
this.rowStyleGenerator = rowStyleGenerator;
- refreshBody();
+ requestRefreshBody();
}
/**