Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Why only show the first digit when focus exited floatitem ?

    Hi,
    After used smartgwtpro-6.0p ,the floatitem had a problem. When I input some digit,but only the first digit is showed,after forcus exit the floatitem. As shown attached picture,and code is:
    FloatItem deliveryUnitLenItem = new FloatItem();
    deliveryUnitLenItem.setName("deliveryUnitLen");
    deliveryUnitLenItem.setTitle(SmartQuote.multiLan.deliveryUnitLen());
    deliveryUnitLenItem.setDecimalPrecision(4);
    //deliveryUnitLenItem.setDecimalPad(2);
    deliveryUnitLenItem.setEditorValueFormatter(new FormItemValueFormatter(){

    @Override
    public String formatValue(Object value, Record record,
    DynamicForm form, FormItem item) {
    if (value == null) return null;
    String val = null;
    try {
    //System.out.println("value:"+value.toString());
    NumberFormat df = NumberFormat.getFormat("#0.0000");
    val = df.format(((Number) value).doubleValue());
    } catch (Exception e) {
    return value.toString();
    }
    return val;
    }


    });

    Why? before use smartgwtpro-6.0p ,the codes work ok.

    Thanks!
    Kingdom
    Attached Files

    #2
    If you provide an editValueFormatter, you need a corresponding parser. Most likely what's going on here is that you're using a decimal separator that is specific to another locale, so the browser's parsing thinks there's garbage after the decimal point. This should have been happening in prior versions too, so perhaps you've not testing exactly the same (eg, locale is not the same).

    Regardless, the simplest fix is to use the new dataSourceField.format feature, which will allow you to delete your custom formatter and not have to worry about a parser.

    Comment

    Working...
    X