diff options
author | Henri Sara <henri.sara@gmail.com> | 2017-03-22 08:37:57 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-03-22 16:45:33 +0200 |
commit | 1ce1ff6a8a694711b90b75ad2494804d1d3c6214 (patch) | |
tree | db8757ff895041cfe1a0e3458dbd60be9f34b7d5 /client | |
parent | 20798ff18a4c8dca8173d263ae36c31271ed56de (diff) | |
download | vaadin-framework-1ce1ff6a8a694711b90b75ad2494804d1d3c6214.tar.gz vaadin-framework-1ce1ff6a8a694711b90b75ad2494804d1d3c6214.zip |
Optimize grid by avoiding redundant row refreshes (#8874)
* Optimize grid by avoiding redundant row refreshes
* Delay more calls to refreshBody()
Diffstat (limited to 'client')
-rwxr-xr-x | client/src/main/java/com/vaadin/client/widgets/Grid.java | 27 |
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(); } /** |