.= 'tag.htm'; break; case 'flag': $pre .= $default_pre .= 'flag.htm'; break; case 'my': $pre .= $default_pre .= 'my.htm'; break; case 'my_password': $pre .= $default_pre .= 'my_password.htm'; break; case 'my_bind': $pre .= $default_pre .= 'my_bind.htm'; break; case 'my_avatar': $pre .= $default_pre .= 'my_avatar.htm'; break; case 'home_article': $pre .= $default_pre .= 'home_article.htm'; break; case 'home_comment': $pre .= $default_pre .= 'home_comment.htm'; break; case 'user': $pre .= $default_pre .= 'user.htm'; break; case 'user_login': $pre .= $default_pre .= 'user_login.htm'; break; case 'user_create': $pre .= $default_pre .= 'user_create.htm'; break; case 'user_resetpw': $pre .= $default_pre .= 'user_resetpw.htm'; break; case 'user_resetpw_complete': $pre .= $default_pre .= 'user_resetpw_complete.htm'; break; case 'user_comment': $pre .= $default_pre .= 'user_comment.htm'; break; case 'single_page': $pre .= $default_pre .= 'single_page.htm'; break; case 'search': $pre .= $default_pre .= 'search.htm'; break; case 'operate_sticky': $pre .= $default_pre .= 'operate_sticky.htm'; break; case 'operate_close': $pre .= $default_pre .= 'operate_close.htm'; break; case 'operate_delete': $pre .= $default_pre .= 'operate_delete.htm'; break; case 'operate_move': $pre .= $default_pre .= 'operate_move.htm'; break; case '404': $pre .= $default_pre .= '404.htm'; break; case 'read_404': $pre .= $default_pre .= 'read_404.htm'; break; case 'list_404': $pre .= $default_pre .= 'list_404.htm'; break; default: $pre .= $default_pre .= theme_mode_pre(); break; } if ($config['theme']) { $conffile = APP_PATH . 'view/template/' . $config['theme'] . '/conf.json'; $json = is_file($conffile) ? xn_json_decode(file_get_contents($conffile)) : array(); } !empty($json['installed']) and $path_file = APP_PATH . 'view/template/' . $config['theme'] . '/htm/' . ($id ? $id . '_' : '') . $pre; (empty($path_file) || !is_file($path_file)) and $path_file = APP_PATH . 'view/template/' . $config['theme'] . '/htm/' . $pre; if (!empty($config['theme_child']) && is_array($config['theme_child'])) { foreach ($config['theme_child'] as $theme) { if (empty($theme) || is_array($theme)) continue; $path_file = APP_PATH . 'view/template/' . $theme . '/htm/' . ($id ? $id . '_' : '') . $pre; !is_file($path_file) and $path_file = APP_PATH . 'view/template/' . $theme . '/htm/' . $pre; } } !is_file($path_file) and $path_file = APP_PATH . ($dir ? 'plugin/' . $dir . '/view/htm/' : 'view/htm/') . $default_pre; return $path_file; } function theme_mode_pre($type = 0) { global $config; $mode = $config['setting']['website_mode']; $pre = ''; if (1 == $mode) { $pre .= 2 == $type ? 'portal_category.htm' : 'portal.htm'; } elseif (2 == $mode) { $pre .= 2 == $type ? 'flat_category.htm' : 'flat.htm'; } else { $pre .= 2 == $type ? 'index_category.htm' : 'index.htm'; } return $pre; } ?>javascript - SAPUI5 - Number Format Localisation - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SAPUI5 - Number Format Localisation - Stack Overflow

programmeradmin0浏览0评论

I have an issue related to number formatting for decimals in different languages. For the CURRENCY control, system takes the correct format based on the language ing from the URL parameter; US and DE ?sap-ui-language=DE or ?sap-ui-language=US

For the input fields which has type=Number attribute, always uses DOT as decimal separator regardless of language setting. Is there a solution for this problem ? I have a dynamic sap.ui.table populated (for both rows and columns) and some rows has number fields and some rows as text fields so i am sending dataformat from the backend dynamically as below;

temp = new sap.m.Input(sColumnId + index,{  value:"{path: '" + sColumnId + "'}" , type:"{DATATYPE}",  textAlign:"Right", liveChange:[handle_livechange,this], change:[handle_change, this] , editable:"{path:'EDITABLE', type:'sap.ui.model.odata.type.String'}" }

since some rows are text based, i cannot hard code formatter as below;

 type:'sap.ui.model.type.Float', formatOptions : {   groupingEnabled: true, groupingSeparator: '.', decimalSeparator : ',', minFractionDigits: 2}}"

I tried custom formatter but somehow on dynamic table my formatter function cannot be found. I tried onChange method to dynamically format but in this case my javascript calculations doesnt work.

If i can control the formatting option based on the row value with expression binding, it will also fix my issue but below code doesn't work.

temp = new sap.m.Input(sColumnId + index,{  value:"{path: '" + sColumnId + ", =${DATATYPE} === 'Number' ? type:'sap.ui.model.type.Float', formatOptions : {   groupingEnabled: true, groupingSeparator: '.', decimalSeparator : ',', minFractionDigits: 2} : type:'sap.ui.model.type.String' }"

I have an issue related to number formatting for decimals in different languages. For the CURRENCY control, system takes the correct format based on the language ing from the URL parameter; US and DE ?sap-ui-language=DE or ?sap-ui-language=US

For the input fields which has type=Number attribute, always uses DOT as decimal separator regardless of language setting. Is there a solution for this problem ? I have a dynamic sap.ui.table populated (for both rows and columns) and some rows has number fields and some rows as text fields so i am sending dataformat from the backend dynamically as below;

temp = new sap.m.Input(sColumnId + index,{  value:"{path: '" + sColumnId + "'}" , type:"{DATATYPE}",  textAlign:"Right", liveChange:[handle_livechange,this], change:[handle_change, this] , editable:"{path:'EDITABLE', type:'sap.ui.model.odata.type.String'}" }

since some rows are text based, i cannot hard code formatter as below;

 type:'sap.ui.model.type.Float', formatOptions : {   groupingEnabled: true, groupingSeparator: '.', decimalSeparator : ',', minFractionDigits: 2}}"

I tried custom formatter but somehow on dynamic table my formatter function cannot be found. I tried onChange method to dynamically format but in this case my javascript calculations doesnt work.

If i can control the formatting option based on the row value with expression binding, it will also fix my issue but below code doesn't work.

temp = new sap.m.Input(sColumnId + index,{  value:"{path: '" + sColumnId + ", =${DATATYPE} === 'Number' ? type:'sap.ui.model.type.Float', formatOptions : {   groupingEnabled: true, groupingSeparator: '.', decimalSeparator : ',', minFractionDigits: 2} : type:'sap.ui.model.type.String' }"
Share Improve this question asked Jun 24, 2017 at 14:51 bilenbilen 1451 gold badge2 silver badges10 bronze badges 6
  • Which values backend can return in {DATATYPE} property? – Andrew Naumovich Commented Jun 24, 2017 at 18:44
  • It is eithet Number or Text . Both formatting working fine but when it is Number, system making decimal seperator as DOT regardless of language setting – bilen Commented Jun 26, 2017 at 0:31
  • Why don't you use it simplier, like this: <Input editable="{EDITABLE}" value="{ path: 'property/value', type: 'sap.ui.model.type.Float'}"/> ? This should automatically take the locale settings to build the correct separators. – Andrew Naumovich Commented Jun 26, 2017 at 5:56
  • in same column, i have different formats. for example row 1 column 1 is text format but row2 column2 is number format, that is why i am trying to arrange my decimals by using localization. – bilen Commented Jul 1, 2017 at 2:54
  • 1 AFAIK only "sap.ui.model.type.Currency" supports localization. But since you have mixed Rows (String / Number) you might have to switch to "sap.ui.model.type.String", write a parser and attach it to the submit-Event – A.vH Commented Jul 3, 2017 at 15:16
 |  Show 1 more ment

1 Answer 1

Reset to default 3

This approach works for me : define the format based on the locale, e.g., in a formatter file :

        sap.ui.define([
            "sap/ui/core/format/NumberFormat"
        ], function (NumberFormat) {     
        var oFloatNumberFormat = NumberFormat.getFloatInstance({
                    maxFractionDigits: 2,
                    minFractionDigits : 2,
                    groupingEnabled: true
                } , sap.ui.getCore().getConfiguration().getLocale());
        }


        return {
                 floatFormat: function(value){
                 return oFloatNumberFormat.format(value);
            },
    }
});

now where you want to use it :

var MyVar= new sap.m.Input({
            value: {
                path: "..../amount" ,
                formatter : function(amount) {
                    return yourdefinedname.floatFormat(amount);
                }
             }
          });
发布评论

评论列表(0)

  1. 暂无评论