Skip to content

Commit

Permalink
fix: override all methods when patching data generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ugur-vaadin committed Nov 12, 2024
1 parent c359c25 commit 982bb82
Showing 1 changed file with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,31 @@ public Column(Grid<T> grid, String columnId, Renderer<T> renderer) {

if (dataGenerator.isPresent()) {
var generator = dataGenerator.get();
DataGenerator<T> conditionalDataGenerator = (item,
jsonObject) -> {
if (Column.this.isVisible()) {
generator.generateData(item, jsonObject);

// Use an anonymous class instead of Lambda to prevent potential
// deserialization issues when used with Grid
// see https://github.com/vaadin/flow-components/issues/6256
var conditionalDataGenerator = new DataGenerator<T>() {
@Override
public void generateData(T item, JsonObject jsonObject) {
if (Column.this.isVisible()) {
generator.generateData(item, jsonObject);
}
}

@Override
public void destroyData(T item) {
generator.destroyData(item);
}

@Override
public void destroyAllData() {
generator.destroyAllData();
}

@Override
public void refreshData(T item) {
generator.refreshData(item);
}
};
columnDataGeneratorRegistration = grid
Expand Down

0 comments on commit 982bb82

Please sign in to comment.