I have a problem with sorting column in browser screen. In my language we use characters like ‘Ö’, ‘É’ and ‘Á’ etc. And if i have a value like ‘Önéletrajz’ (CV), and I want to sort that column ascending, it will put that word into the bottom of the column, and at us, in our abc, it comes after O letter. How could I fix it?
I guess cuba or Vaadin thinks it is a special character and this is the reason, why it is sorting wrong.
Hi,
Thank you or reporting the problem. We are going to fix it in the platform.
Unfortunately, there is no simple way to workaround the issue, but you can do the following:
Create a custom datasource in Studio (specifyDatasource class).
Open the created class in IDE
Override the getEntities() method. For instance, as follows. As result, sorted items will be loaded from the DB.
To fix in-memory reordering, specify custom EntityComparator by overriding the createEntityComparator() method.
public class MyDsClass extends CustomCollectionDatasource<NewEntity, UUID> {
private DataManager dataManager = AppBeans.get(DataManager.class);
@Override
protected Comparator<NewEntity> createEntityComparator(){
if (sortInfos[0].getPropertyPath() != null) {
final MetaPropertyPath propertyPath = sortInfos[0].getPropertyPath();
final boolean asc = Sortable.Order.ASC.equals(sortInfos[0].getOrder());
return new MyEntityComparator<>(propertyPath, asc);
} else {
// If we can not sort the datasource, just return the empty comparator.
return (o1, o2) -> 0;
}
}
@Override
protected Collection<NewEntity> getEntities(Map<String, Object> params) {
LoadContext<NewNewEntity> loadContext = LoadContext.create(NewNewEntity.class)
.setQuery(LoadContext.createQuery("select p from test$NewEntity p order by p.newField"));
List<NewNewEntity> orderedEntities = dataManager.loadList(loadContext);
return orderedEntities;
}
}