I'm trying to use a default value when a user clicks on a button that invokes ListGrid.startEditingNew() and display the value as a mega unit (divided by 1,000,000) but stored as a regular unit. With my code below, when I press the add button, the default value shows up in the editor without formatting. Is there anyway to get to display as formatted? For example, if my default value is 1000000, I'd like the editor to contain 1 when the add button is pressed and then saved as 1000000 after the user finishes editing. Thanks for your help!
I'm using SmartGWT 2.5p in FF.
This is my code:
I'm using SmartGWT 2.5p in FF.
This is my code:
Code:
ListGridField field = new ListGridField("field"); field.setDefaultValue(1000000); // should display as 1 field.setEditValueParser(new CellEditValueParser() { public Object parse(Object value, ListGridRecord record, int rowNum, int colNum) { // user enters values as mega unit. Store in regular unit return ValueUtils.toFloat(value) * 1000000; } }); field.setEditValueFormatter(new CellEditValueFormatter() { public Object format(Object value, ListGridRecord record, int rowNum, int colNum) { // stored in regular unit. Display as mega unit return ValueUtils.toFloat(value) / 1000000; } }); field.setCellFormatter(new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { // for when fetching data from data source return ValueUtils.toFloat(value) / 1000000; } }); ListGrid listGrid = new ListGrid(); listGrid.setFields(field);
Comment