我有一个包含多列的vaadin表。其中一列属于标签类。
container.addContainerProperty(ID_COLUMN, Label.class, "");我把它装满了
referenceItem.getItemProperty(ID_COLUMN).setValue(new Label(new Integer(reference.getId()).toString()));当我单击此表对表进行排序时,它会对数据排序如下
1
10
100
2
200
7因此,我尝试将类更改为Integer,然后它运行良好,但我得到的数字与逗号类似
1
2
...
..
7,456
8,455如何对数据进行数字排序而不使用逗号。
发布于 2017-10-25 21:45:41
我想出了办法。我在专栏中使用了Integer作为类,并使用了以下方法
referenceTable = new Table()
{
@Override
protected String formatPropertyValue(final Object a_row_id, final Object a_col_id, final Property<?> a_property)
{
if (a_property.getType() == Integer.class && null != a_property.getValue())
{
DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(getLocale());
df.applyLocalizedPattern("#0");
return df.format(a_property.getValue());
}
return super.formatPropertyValue(a_row_id, a_col_id, a_property);
}
};发布于 2017-10-25 21:48:44
我已经有一段时间没有和Vaadin Table玩过了。
有属性格式化器,生成器等.但在这种情况下,最简单的方法是:
container.addContainerProperty(ID_COLUMN, String.class, "");
referenceItem.getItemProperty(ID_COLUMN).setValue(""+reference.getId());https://stackoverflow.com/questions/46937436
复制相似问题