Announcement

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

    Float Values truncated in listgrid fields

    If we are putting a value with 13 digits + upto 4 decimal places for a float field nd moving out of field it automatically round it upto 3 decimals
    eg.1234567891234.3278 truncated to 1234567891234.328 on focus out
    *upto 12 digits+4 decimal .it is working fine.
    for 15 digits + 4decimal 123456789123456.2358---->
    123456789123456.23 it is even not rounding off but truncating the decimal precision

    I am not founding any other data type for listgrid field also .
    I need 16digits+upto4 decimal places
    please suggest a solution thanx in adv.

    #2
    I've put in these range n validations............


    validators:[{type:"floatRange", min:0.0001,max:9999999999999999.9999},
    {type:"floatPrecision", precision:4}],
    defaultValue:"0.0",
    editorProperties:{length:21},

    Comment


      #3
      You're running out of precision with the JavaScript Number object. Try specifying those same numbers directly in code and then calling toString() on them and you'll see what we mean.

      Comment


        #4
        Hi everyone,
        Did you get this fixed? I have the same problem currently (where the decimal is truncated) and not sure how to fix it.

        I saw an example on the showcase that does this to a listgridfield, but i have a datasourcefloatField. Please advise. Thanks!

        # final ListGridField populationField = new ListGridField("population", "Population");
        # populationField.setType(ListGridFieldType.INTEGER);
        # populationField.setCellFormatter(new CellFormatter() {
        # public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
        # if (value == null) {
        # return null;
        # } else {
        # NumberFormat nf = NumberFormat.getFormat("0,000");
        # try {
        # return nf.format(((Number) value).longValue());
        # } catch (Exception e) {
        # return value.toString();
        # }
        # }
        # }
        # });


        I actually found an answer to my own question shortly after. I changed float to be String and formatted the number value to have 2 decimal places using DecimalFormat.
        Last edited by vnta; 9 Aug 2010, 07:04.

        Comment


          #5
          I am looking for a SmartClient 8.0 developer for a 1 or 2 page application to start with.

          Can someone please tell me how to find one?

          David

          www.RescueMissionForChildren.org

          davidasa88@gmail.com

          Comment

          Working...
          X