IndexedContainer icLoaded = new IndexedContainer();
icLoaded.removeAllItems();
icLoaded.removeAllContainerFilters();
icLoaded.addContainerProperty(“Average Cost”, Double.class, null);
In the model i have the below code
public IndexedContainer DoFetchstockCodesTable(String passedSQL,
IndexedContainer passTable, String CustomsaleQuerry) {
try {
Class.forName(dbsettings.dbDriver);
final Connection conn = DriverManager.getConnection(
new Home().GiveMeSessionDB(), dbsettings.dbUsername,
dbsettings.dbPassword);
final Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(passedSQL.trim());
while (rs.next()) {
passTable.addItem(rs.getString("item_id"));
passTable.getContainerProperty(rs.getString("item_id"),
"Average Cost").setValue(rs.getDouble("average_cost"));
How can i convert the below
passTable.getContainerProperty(rs.getString(“item_id”),
“Average Cost”).setValue(rs.getDouble(“average_cost”));
to display a number with 2 decimal places separated by a comma separator like 1,000.12 using
NumberFormat numberFormat = new DecimalFormat(“#,###.00”);
When i use the below , nothing gets displayed .
But the formatter sets String values. Strange that you don’t get an IllegalArgumentException.
Setting the type to String should solve this, but then the sorting of that column will be sorted String-wise, which is not desirable.
So, a better option would be to let the container contain Double for that property id, but add a Converter to the table so that only the visual representation changes: