从XML视图多次调用格式化程序

2020-08-30 23:58发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)你好,我创建了一个格式化程序来显...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


你好,我创建了一个格式化程序来显示" i18n"模型中的文本。

页面(视图)开始时,格式化程序内的函数" ageDescription" 调用3次

  1. sBirthday是" 未定义"
    sFormat是" 未定义"
  2. sBirthday正确计价
    sFormat为" 未定义"
  3. sBirthday正确计价
    sFormat正确计价

为什么会这样?
是正确的吗?
我如何处理不管理"未定义"值的函数?

formatter.js

 sap.ui.define([
 "工具/时刻"
 ],函数(DateFormat){
 "使用严格";
 返回{
 ageDescription:函数(sBirthday,sFormat){
 var oBundle = this.getView()。getModel(" i18n")。getResourceBundle();
 var sAge = oBundle.getText(" tooYoung");
 var sFromMyBd = moment(sBirthday,sFormat).fromNow();
 做一点事();
 返回年龄;
 }
 }
 });
 

main.controller.js

 sap.ui.define([
    " sap/ui/core/mvc/Controller",
    " sap/ui/model/json/JSONModel",
    " sap/ui/model/resource/ResourceModel",
    " sap/m/library",
    "模型/格式化程序"
 ],函数(控制器,JSONModel,ResourceModel,mobileLibrary,格式化程序){
 "使用严格";
 return Controller.extend(" controller.main",{
 格式化程序:formatter,
 onInit:function(){
 做一点事();
 }
  });
 }); 

main.view.xml

 

 
 
2条回答
nice_wp
2020-08-31 00:34

嗨,

我的格式化程序不同:

.js

 sap.ui.define([],function(){
 "使用严格";

 返回{

 formatterVisiblePrest:函数(FLAG,TIPO){

 var vis = false;
         if(FLAG ===" X" && TIPO!==" X"){
                vis = true;
                       }
 返回
 },
 };
 });
 

.xml

 <按钮工具提示=" {i18n> AggiungiAtt}" visible =" {部分:[{path:'TabAttRV> FLAG'},{path:'TabAttRV> TIPO'}],格式化程序:'。formatter.formatterVisibleAtt'  }" id =" idAggiungiButton" enabled =" {= $ {TabAttRV> FLAG} ==='X'}" press =" onAggiungiAttivita" 

一周热门 更多>