Announcement

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

    Formula field in locale format?

    Hi,
    is it possible for end user who is defining a grid's formula field (say A+B) to format output according to his locale?
    Thanks,
    MichalG

    #2
    If you have loaded a locale (see Internationalization overview) then formatting will be locale-specific for formula outputs.

    Regards
    Isomorphic Software

    Comment


      #3
      Hi,
      This what I have got in the html file:
      Code:
              <meta http-equiv="content-type" content="text/html; charset=UTF-8">
              <meta name="gwt:property" content="locale=pl">
      and in gwt.xml:
      Code:
          <extend-property name="locale" values="en"/>
          <extend-property name="locale" values="pl"/>
          <set-property-fallback name="locale" value="pl"/>
      and have no issues with framework localization at all.
      But if I define formula column like: A/3.14
      then output in new column cells has .(point) as decimal separator not ,(comma) which is used in pl locale?
      MichalG

      Comment


        #4
        Also note that evaluating JS expression in the Developer console within our application shows:
        Code:
        Evaluator: result of 'NumberUtil.decimalSymbol' (1ms):
        ","
        which is correct for pl locale, but not used as formula column output.
        MichalG

        Comment


          #5
          We just tested this same scenario and it worked as expected. Make sure you are using the latest patched version, and if the problem persists, tell us what version of what product you are using (remember to always post this information).

          Comment


            #6
            OK, so maybe I am missing something.
            This is a standalone test case using recommended internationalization methods:
            index.html
            Code:
            <!DOCTYPE html>
            
            <html>
                <head>
            
                    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
                    <meta name="gwt:property" content="locale=pl">
            
                    <title>Client</title>
            
                </head>
            
                <body>
            
                    <script type="text/javascript">
                        var isomorphicDir = "./sc/";
                    </script>
            
                    <script src="sc/modules-debug/ISC_Core.js">          </script>
                    <script src="sc/modules-debug/ISC_Foundation.js">    </script>
                    <script src="sc/modules-debug/ISC_Containers.js">    </script>
                    <script src="sc/modules-debug/ISC_Grids.js">         </script>
                    <script src="sc/modules-debug/ISC_Forms.js">         </script>
                    <script src="sc/modules-debug/ISC_RichTextEditor.js"></script>
                    <script src="sc/modules-debug/ISC_Calendar.js">      </script>
                    <script src="sc/modules-debug/ISC_DataBinding.js">   </script>
            
                    <script src="sc/skins/Graphite/load_skin.js"></script>
            
                    <script src="pl.com.tech4.index.nocache.js"></script>
            
                </body>
            </html>
            index.gwt.xml
            Code:
            <module>
            
                <!-- Inherit the core Web Toolkit stuff -->
                <inherits name='com.google.gwt.user.User'/>
                <!-- GWT internationalization -->
                <!--inherits name="com.google.gwt.i18n.I18N"/-->
            
                <!--inherits name="com.smartgwt.SmartGwtNoScript"/-->
                <inherits name="com.smartgwt.debug.SmartGwtNoScriptDebug"/>
            
                <!-- only necessary with SmartGwtNoScript -->
                <inherits name="com.smartclient.theme.graphite.GraphiteResources"/>
            
                <inherits name="com.smartgwt.tools.SmartGwtTools"/>
            
                <!--inherits name="com.reveregroup.gwt.imagepreloader.ImagePreloader" /-->
            
                <entry-point class="pl.com.tech4.client.MainEntryPoint"/>
            
                <!--extend-property name="locale" values="en"/-->
                <extend-property name="locale" values="pl"/>
                <set-property-fallback name="locale" value="pl"/>
            
                <set-property name="user.agent" value="safari"/>
                <!--set-property name="user.agent" value="gecko1_8,ie6,ie8"/-->
            
                <!-- SuperDevMode -->
                <add-linker name="xsiframe"/>
                <set-configuration-property name="devModeRedirectEnabled" value="true"/>
                <!-- enable source maps -->
                <set-property name="compiler.useSourceMaps" value="true" />
            
            </module>
            Sample code
            Code:
            package pl.com.tech4.client;
            
            import com.google.gwt.core.client.EntryPoint;
            import com.smartgwt.client.data.DataSourceField;
            import com.smartgwt.client.data.RestDataSource;
            import com.smartgwt.client.data.fields.DataSourceFloatField;
            import com.smartgwt.client.data.fields.DataSourceTextField;
            import com.smartgwt.client.widgets.grid.ListGrid;
            
            public class MainEntryPoint implements EntryPoint {
            
                public void onModuleLoad() {
            
                    layout();
                }
            
                private void layout() {
            
                    final RestDataSource ds = new RestDataSource();
                    ds.setDataURL("UnitDir.xml");
                    DataSourceField fieldId = new DataSourceField();
                    fieldId.setName("id");
                    fieldId.setPrimaryKey(true);
                    fieldId.setHidden(true);
                    DataSourceTextField fieldCode = new DataSourceTextField();
                    fieldCode.setName("code");
                    DataSourceFloatField fieldQuantity = new DataSourceFloatField();
                    fieldQuantity.setName("quantity");
                    ds.setFields(fieldId, fieldCode, fieldQuantity);
            
                    ListGrid lg = new ListGrid();
                    lg.setDataSource(ds);
                    lg.setAutoFetchData(true);
                    lg.setCanAddFormulaFields(true);
                    lg.setWidth(300);
            
                    lg.draw();
                }
            }
            Running this code shows the following view:
            Click image for larger version  Name:	formulaColumnFormat1.png Views:	1 Size:	5.6 KB ID:	250010
            which shows dot as decimal point (instead of comma) in quantity values, so I think that numeric localization is wrong here already, although I have no idea why. Interface messages and NumberUtil.decimalSymbol show in pl locale.
            Consequently adding formula column:
            Click image for larger version  Name:	formulaColumnFormat2.png Views:	1 Size:	30.9 KB ID:	250011
            creates new numeric column, but values not formated according to locale set:
            Click image for larger version  Name:	formulaColumnFormat3.png Views:	1 Size:	9.3 KB ID:	250012
            Any suggestions what I have done wrong are welcome.
            MichalG
            ps using up-to-date production SmartClient Version: v11.1p_2017-10-26/LGPL Development Only (built 2017-10-26)
            Last edited by michalg; 27 Oct 2017, 02:32.

            Comment


              #7
              We had a miscommunication and what was tested was actually a different scenario.

              If you create a formula field in *code*, you can use setFormat() to apply a format, and that format will use locale-specific formatting.

              The only way to influence formatting for a user-added formula field would be to add a grid-wide CellFormatter (with ListGrid.setCellFormatter()), leave normal fields alone and add formatting for formula fields.

              Note that we're considering adding a new property such as listGrid.defaultNumericFormat to make this kind of thing easier, but that would be for the next release.

              Comment


                #8
                Ok, thanks.
                MichalG

                Comment

                Working...
                X