Announcement

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

    How to Set "localeFloat" Type for Non DataBound LIstGridField

    Hi Isomorphic. I have an small list of parameters displayed in a ListGrid, which isn't DataBound, so I create and add the fields manually to the ListGrid, and then populate the ListGrid with grid.setData() (by also creating the records manually with each parameter's 'Name' and default 'Value').

    I want to have the 'Value' field displayed with the proper decimal and thousands separator. I am aware of the setCellFormatter(), setEditValueFormatter() and setEditValueParser() APIs, and I have a working solution using those, but this approach seems error prone and that will require some effort to maintain.

    Knowing that for DataBound ListGridFields this is achieved so easily by just adding type="localeFloat" in the ds.xml field definition, I wanted to know if there's an API like that for my non DataBound ListGridFields?

    Thanks

    I am using SmartGWT 6.0p 2016-09-17

    #2
    It seems like you did not notice that ListGridField allows setType() and also setFormat().

    Comment


      #3
      Hi Isomorphic. Yes, I did notice setType(). Sorry for not mentioning it. But it takes a ListGridFieldType, which currently doesn't include LOCALEFLOAT (and the similar). Are these types supposed to be supported here?

      Regarding setFormat(), I didn't think about it before, but will give it a try and let you know how it goes.

      Thanks!

      Comment


        #4
        Hi Isomorphic. Well, the result with setFormat() is not the same as the one I get when I use type="localeFloat" in the ds.xml field definition, because when I go to edit the field, the current locale symbols are not respected, and the default symbols are used instead.

        For example, if the underlying value is 0.6667, and I use setFormat(",0.####") when the locale is 'es', the value will be properly displayed as 0,6667 (comma as decimal separated, as expected). But if I start to edit the field value, the editor turns to 0.6667 again (notice the period as decimal separator), which is confusing to the final user.

        At this point I would think that something like setEditFormat() could be used, but that isn't available, so I need to start defining custom formatters again, which is what I want to avoid in the first place.

        So maybe setType() would be the proper solution here, but as I mentioned, as it stands, it currently doesn't support LOCALEFLOAT, LOCALECURRENCY or LOCALEINT.

        Would you consider adding support for these ListGridFieldTypes?

        Thanks

        Comment


          #5
          As documented "format" affects formatting (not parsing) so this result is expected when you have not set the type to "localeFloat".

          Currently, if you don't have a DataSource and don't want to create one (which is useful for other reasons, like filtering..) you would have to call setAttribute("type", "localeFloat"). However, we do plan to add these additional values to the enum, for convenience in this edge case.

          Comment


            #6
            We have added the requested values and others to the enum, as well as the ListGridField.setType(SimpleType) API. Please try the next nightly build, dated September 22.

            Regards
            Isomorphic Software

            Comment


              #7
              Thanks Isomorphic. I will try it and let you know how it goes...

              Comment


                #8
                Hi Isomorphic. I can confirm that as of today, ListGridFieldType includes LOCALEFLOAT, LOCALECURRENCY or LOCALEINT and other types.
                Thanks!

                Comment

                Working...
                X