on 01-27-2016 6:54 PM
Hi There,
I am getting error on following code:
Error - "test4odata" is not defined.
where I am doing wrong?
-----------------------------------------------------------------------------------------------
jQuery.sap.declare("test4odata.model.formatter");
sap.ui.define(function() {
"use strict";
test4odata.model.formatter = {
status: function(Price) {
if (Price == undefined) {
try {
var nPrice = Math.ceil(Price);
if (nPrice < 10) {
return "lower";
} else if (nPrice > 10) {
return "higher";
} else {
return "Error";
}
} catch (err) {
return "None";
}
} else {
alert("undefined");
}
}
};
}, /* bExport= */ true);
------------------------------------------------------------------------------------
regards.
Laboni.
post the code how you reference it, definition looks ok
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is my view
-------------------------------------------------------------------------
<mvc:View
controllerName="test4odata.controller.View1"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<App>
<pages>
<Page title="{i18n>title}">
<content>
<Table
items = "{/Products}">
<columns>
<Column>
<Text text ="Rating"/>
</Column>
<Column>
<Text text= "Price"/>
</Column>
<Column>
<Text text= "status"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text = "{Rating}"/>
<Text text= "{Price}"/>
<Text text = "{
path: '/Price',
formatter:'test4odata.model.formatter.status '
}" />
</cells>
</ColumnListItem>
</items>
</Table>
</content>
</Page>
</pages>
</App>
</mvc:View>
------------------------------------------------------------
this is my controller file.
-----------------------------------------------------------
jQuery.sap.require("test4odata.model.formatter");
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("test4odata.controller.View1", {
onInit: function() {
var oModel = new sap.ui.model.odata.ODataModel("/destinations/NorthwindV2/V2/OData/OData.svc",true);
/* oModel.read('/Products', null, null, true, function(oData, oResponse){
alert("fhhjfhjf");
});
*/
this.getView().setModel(oModel);
}
});
});
----------------------------------------------------
this is my index.html
-------------------------------------------------
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<title>test4odata</title>
<script id="sap-ui-bootstrap"
src="../../resources/sap-ui-core.js"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-compatVersion="edge"
data-sap-ui-resourceroots='{"test4odata": ""}'>
</script>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script>
sap.ui.getCore().attachInit(function() {
new sap.m.Shell({
app: new sap.ui.core.ComponentContainer({
height : "100%",
name : "test4odata"
})
}).placeAt("content");
});
</script>
</head>
<body class="sapUiBody" id="content">
</body>
</html>
---------------------------------------------------------
this is my project structure.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.