Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add the header component after a refresh event #36

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ package-lock.json
package.json
webpack.config.js
webpack.generated.js
vite.generated.ts

enhanced-grid-flow/src/main/resources/rebel.xml
.classpath
.project
.settings
.vscode/settings.json

enhanced-grid-flow-demo/frontend/generated
enhanced-grid-flow-demo/src/main/dev-bundle
enhanced-grid-flow-demo/frontend/index.html
enhanced-grid-flow-demo/tsconfig.json
enhanced-grid-flow-demo/types.d.ts
enhanced-grid-flow-demo/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.renderer.NumberRenderer;
import com.vaadin.flow.router.PreserveOnRefresh;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.router.RouteAlias;

Expand All @@ -27,6 +28,7 @@
*/
@Route(value = "", layout = MainLayout.class)
@RouteAlias(value = "single-grid", layout = MainLayout.class)
@PreserveOnRefresh
public class SimpleSingleSelectView extends Div {

public SimpleSingleSelectView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
*/

import java.util.Comparator;

import org.apache.commons.lang3.StringUtils;
import java.util.Optional;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.HasValueAndElement;
Expand All @@ -38,7 +37,8 @@
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.data.renderer.Renderer;
import com.vaadin.flow.function.ValueProvider;
import com.vaadin.flow.internal.HtmlUtils;
import com.vaadin.flow.router.BeforeEnterEvent;
import com.vaadin.flow.router.BeforeEnterObserver;

/**
*
Expand All @@ -48,7 +48,7 @@
*/
@Uses(Icon.class)
@JsModule(value = "./src/enhanced-grid-sorter.js")
public class EnhancedColumn<T> extends Grid.Column<T> {
public class EnhancedColumn<T> extends Grid.Column<T> implements BeforeEnterObserver {

private HasValueAndElement<?, ? extends FilterFieldDto> filter;

Expand Down Expand Up @@ -285,4 +285,15 @@ protected void setFilterIcon(Icon icon) {
public EnhancedColumn<T> setKey(String key) {
return (EnhancedColumn<T>) super.setKey(key);
}

@Override
public void beforeEnter(BeforeEnterEvent beforeEnterEvent) {
if (beforeEnterEvent.isRefreshEvent()) {
Optional.ofNullable(this.getHeaderComponent())
.ifPresent(headerComponent -> {
this.setHeader(headerComponent);
this.updateFilterButtonStyle();
});
}
}
}
Loading