diff --git a/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java b/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java index dc1787cd..23e6b3e5 100755 --- a/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java +++ b/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java @@ -40,6 +40,7 @@ import com.vaadin.flow.component.ComponentEvent; import com.vaadin.flow.component.ComponentEventListener; import com.vaadin.flow.component.ComponentUtil; +import com.vaadin.flow.component.DetachEvent; import com.vaadin.flow.component.Focusable; import com.vaadin.flow.component.HasElement; import com.vaadin.flow.component.HasSize; @@ -3011,6 +3012,18 @@ public void sort(List> order) { protected void onAttach(AttachEvent attachEvent) { super.onAttach(attachEvent); updateClientSideSorterIndicators(sortOrder); + if (getDataProvider() != null && dataProviderChangeRegistration == null) { + handleDataProviderChange(getDataProvider()); + } + } + + @Override + protected void onDetach(DetachEvent detachEvent) { + if (dataProviderChangeRegistration != null) { + dataProviderChangeRegistration.remove(); + dataProviderChangeRegistration = null; + } + super.onDetach(detachEvent); } private void setSortOrder(List> order,