Skip to Content
0
Mar 18, 2014 at 12:25 PM

Formatter in SAP Fiori like application

182 Views

Hi,

I am trying to use Formatter following same steps like "EXERCISE 3 – FORMATTER" in 'Building SAP Fiori-like UIs with SAP ui5' PDF.

But its not working.So Please help me in creating formatter using Json model and XML view.

Below is my code:

XML View:

<List

items="{/ProductCollection}"

headerText="Products">

<items>

<ObjectListItem

title="{Name}"

number="{number}"

numberUnit="{CurrencyCode}">

<firstStatus>

<ObjectStatus

text="{

path: 'LifecycleStatus',

formatter: 'util.Formatter'.statusText'

}"

state="{

path: 'LifecycleStatus',

formatter: 'util.Formatter'.statusState'

}" />

</firstStatus>

<attributes>

<ObjectAttribute text="{textobjstatus}" />

<ObjectAttribute text="{CreatedByName}" />

</attributes>

</ObjectListItem>

</items>

</List>

Controller:

onInit: function() {

oData = {"ProductCollection":

[

{"Name":"abc","number":"123","CurrencyCode":"EUR","LifecycleStatus":"P","textobjstatus":"Manager","CreatedByName":"11/03/2002"},

{"Name":"def","number":"345","CurrencyCode":"EUR","LifecycleStatus":"P","textobjstatus":"Team Lead","CreatedByName":"04/03/2006"},

{"Name":"ghi","number":"456","CurrencyCode":"EUR","LifecycleStatus":"N","textobjstatus":"Team Lead","CreatedByName":"04/03/2006"},

{"Name":"jkl","Price":"789","CurrencyCode":"EUR","LifecycleStatus":"N","textobjstatus":"Team Lead","CreatedByName":"04/03/2006"},

]};

// create JSON model instance

var oModel = new sap.ui.model.json.JSONModel();

// set the data for the model

oModel.setData(oData);

// set the model to the core so that different controls can use the model

//sap.ui.getCore().setModel(oModel);

this.getView().setModel(oModel);

},

Please help...........

Regards,

Sowmya