Browse Source

Fix Grid Column not sortable with backend data and sort property (#10811)

tags/8.5.0.alpha1
Teemu Suo-Anttila 6 years ago
parent
commit
da8f5adcae

+ 8
- 5
server/src/main/java/com/vaadin/ui/Grid.java View File

*/ */
public Column<T, V> setSortProperty(String... properties) { public Column<T, V> setSortProperty(String... properties) {
Objects.requireNonNull(properties, "Sort properties can't be null"); Objects.requireNonNull(properties, "Sort properties can't be null");
sortOrderProvider = dir -> Arrays.stream(properties)
.map(s -> new QuerySortOrder(s, dir));
return this;
return setSortOrderProvider(dir -> Arrays.stream(properties)
.map(s -> new QuerySortOrder(s, dir)));
} }


/** /**
Objects.requireNonNull(provider, Objects.requireNonNull(provider,
"Sort order provider can't be null"); "Sort order provider can't be null");
sortOrderProvider = provider; sortOrderProvider = provider;

// Update state
updateSortable();

return this; return this;
} }


setSortable(false); setSortable(false);
} }
if (design.hasAttr("editable")) { if (design.hasAttr("editable")) {
/*
/**
* This is a fake editor just to have something (otherwise * This is a fake editor just to have something (otherwise
* "setEditable" throws an exception. * "setEditable" throws an exception.
* *
* the mode in to which Grid should be set * the mode in to which Grid should be set
*/ */
public void setHeightMode(HeightMode heightMode) { public void setHeightMode(HeightMode heightMode) {
/*
/**
* This method is a workaround for the fact that Vaadin re-applies * This method is a workaround for the fact that Vaadin re-applies
* widget dimensions (height/width) on each state change event. The * widget dimensions (height/width) on each state change event. The
* original design was to have setHeight and setHeightByRow be equals, * original design was to have setHeight and setHeightByRow be equals,

+ 1
- 1
server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java View File



Assert.assertTrue("Column should be marked sortable", Assert.assertTrue("Column should be marked sortable",
column.isSortable()); column.isSortable());
Assert.assertFalse(
Assert.assertTrue(
"User should be able to sort the column with the sort order", "User should be able to sort the column with the sort order",
column.isSortableByUser()); column.isSortableByUser());
} }

Loading…
Cancel
Save