当我尝试以编程方式对网格进行排序时,会出现此错误:
grid.sort(List.of(
new GridSortOrder<>(grid.getColumnByKey("Νο"), SortDirection.ASCENDING),
new GridSortOrder<>(grid.getColumnByKey("επίθετο"), SortDirection.ASCENDING)
));
错误:
无法调用"com.vaadin.flow.component.grid.grid$Column.getInternalId(("因为"0"的返回值;com.vaadin.flow.component.grid.GridSortOrder.getSorted(("为空
是因为我在Grid
列中使用了希腊字符吗?你知道什么解决方案或变通方法吗?
为了调用grid.getColumnByKey()
,您需要为每列设置键。这还可以:
final String COL1 = "Νο";
final String COL2 = "επίθετο";
Grid<SomeBean> grid = new Grid<>();
grid.addColumn(SomeBean::getId).setHeader("Column 1").setKey(COL1);
grid.addColumn(SomeBean::getName).setHeader("Column 2").setKey(COL2);
grid.sort(List.of(
new GridSortOrder<>(grid.getColumnByKey(COL1), SortDirection.ASCENDING),
new GridSortOrder<>(grid.getColumnByKey(COL2), SortDirection.ASCENDING)
));