Skip to Content
0
Former Member
Apr 18, 2014 at 08:35 AM

Formatter issue

411 Views

I have a strange issue at hand. I am trying to apply a formatter to format date to one of the fields but the formatter function never gets invoked.

I tried with XMl and JS views but non of them seems to work is there any trick I am missing.

I am also using lazy loading because I thought eager loding of views might be issue but no use.

Here is code in contention

var oTemplate = new sap.m.ColumnListItem({
  type:"Navigation",
  press:oController.handleProjectSelected,

  cells:[
        new sap.m.ObjectIdentifier({title:"{displayName}"}),
       
        new sap.m.Text({
        path:"creationDate",
        formatter:"util.Formatter.date"
        }),
       
        new sap.m.Label({
        text:"{creatorUserName}"
        }),
       
        new sap.m.Text({
        path:"lastDataUpdateDate",
        formatter:"util.Formatter.date"
        })
       
       
        ]
  });

//Same for XML view

<ColumnListItem
  type="Navigation"
  press="handleProjectSelected">

  <cells>
  <ObjectIdentifier title="{displayName}"/>
  <Text text="{
  path:'creationDate',
  formatter:'util.Formatter.date'
  }"/>
  <Text text="{creatorUserName}"/>
  <Text text="{
  path:'lastDataUpdateDate',
  formatter:'util.Formatter.date'
  }"/>
  </cells>
  <customData>
  <core:CustomData
  key="target"
  value="Project"/>
  </customData>

  </ColumnListItem>

Here is Formatter code it never gets invoked

jQuery.sap.declare("util.Formatter");


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


util.Formatter = {



  date : function (value) {
  if (value) {
  var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "yyyy-MM-dd"});
  return oDateFormat.format(new Date(value));
  } else {
  return value;
  }
  }
};