2016-12-19 6 views
0

私はこの単純なフォーマッタを動作させるのに苦労しており、何が間違っているのか分かりません。UI5フォーマッタが動作しない

ap.ui.jsview("splitapp.DetailPage", { 

    getControllerName: function() { 
     return "splitapp.DetailPage"; 
    }, 

    createContent: function(oController) { 

     jQuery.sap.require("sap.ui.core.format.DateFormat"); 

     var oType = new sap.ui.model.type.DateTime({ 
      source: { 
       pattern: "yyyy-MM-dd HH:mm:ss Z" 
      } 
     }); 
     var oDateFormat = sap.ui.core.format.DateFormat.getInstance({ 
      pattern: "MM/dd/yyyy" 
     }); 

     oLayout.createRow(new sap.ui.commons.TextView({ 
       text: "Fecha de apertura", 
       design: sap.ui.commons.TextViewDesign.Bold 
      }), 
      new sap.ui.commons.TextView({ 
       text: { 
        path: "ticketSelected>/fechaApertura", 
        type: oType, 
        formatter: function(d) { 
         return oDateFormat.format(new Date(d)) 
        } 
       } 
      }) 
     ); 
    } 
}); 

答えて

0

唯一の問題は、フォーマッタであなたのd値は""空の文字列になるだろう。..

formatter: function(d) { 
    var date = new Date(); //or any default value you want to set 
    if (d) { 
     date = new Date(d); 
    } 
    return oDateFormat.format(date); 
} 

Working JSFiddle here

+0

は、しかし、私はまだ、なぜ私のコードでは得ることはありません、あなたのスニルをありがとうdは空の文字列になりますが、あなたのフィドルでは、タイプ:oTypeプロパティをコメントアウトして、それがどのように動作するかについて何か忘れていると思います。 –

+0

ところで、あなたのフィドルは私の問題を解決しました。ありがとうございました! –

関連する問題