on 08-03-2022 8:30 PM
Hi All,
I have to display a table with three columns, and third column should have value from entityset zentity2 ( ID, Description)
Entity1 is the actual display of table ( name, flag ,desc{ three values from zentity2 as dropdown}).
Code in my view
<ColumnListItem>
<cells>
<ObjectIdentifier text="{name}"></ObjectIdentifier>
<ObjectIdentifier text="{flag}"></ObjectIdentifier>
<ObjectIdentifier text="{desc}"></ObjectIdentifier>
<Text text="{desc}"/>
<Select items="{entity2}">
<!-- here's the relative dropdown binding -->
<core:Item key="{id}" text="{Description}"/>
</Select>
</cells>
</ColumnListItem>
In My Controller
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(oData);
this.getView().setModel(oModel);
As of now, I see a table with just three columns and no drop down in description column.
You need a "/" before the entity2 set, otherwise it thinks entity2 is a property of entity1
<cells>
<ObjectIdentifier text="{name}"></ObjectIdentifier>
<ObjectIdentifier text="{flag}"></ObjectIdentifier>
<Select items="{/entity2set}" selectedKey="{id_in_entity1}">
<core:Item key="{id}" text="{Description}"/>
</Select>
</cells><br>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @rshafaiottawa, Thanks.
My Meta data for Entity1 is below , as you can see in my view below , I am displaying only procdesc,optinflg and zfreqdes (need this as drop down) , Attaching the error as well.error.png
{
"d" : {
"results" : [
{
"__metadata" : {
"id" : "http://jfbsapags01.genmills.com:36520/sap/opu/odata/sap/ZSD_CUSTOMER_360_SRV/ZZCONTACT360(proctyp='ZALO',freqid=1)",
"uri" : "http://jfbsapags01.genmills.com:36520/sap/opu/odata/sap/ZSD_CUSTOMER_360_SRV/ZZCONTACT360(proctyp='ZALO',freqid=1)",
"type" : "ZSD_CUSTOMER_360_SRV.ZZCONTACT360Type"
},
"proctyp" : "ZALO",
"freqid" : 1,
"procdesc" : "04 ALLOCATION AUTO-CUT",
"optinflg" : "X",
"zfreqdesc" : "ONCE PER DAY"
},
My Metadata for entity2 is below , This has totally 3 rows of data, which is what i am expecting to see in my drop down.
"d" : {
"results" : [
{
"__metadata" : {
"id" : "http://jfbsapags01.genmills.com:36520/sap/opu/odata/sap/ZSD_CUSTOMER_360_SRV/Z_FREQDESC360(freqid=1,zfreqdesc='ONCE%20PER%20DAY')",
"uri" : "http://jfbsapags01.genmills.com:36520/sap/opu/odata/sap/ZSD_CUSTOMER_360_SRV/Z_FREQDESC360(freqid=1,zfreqdesc='ONCE%20PER%20DAY')",
"type" : "ZSD_CUSTOMER_360_SRV.Z_FREQDESC360Type"
},
"freqid" : 1,
"zfreqdesc" : "ONCE PER DAY"
},
I changed my View like this
<content>
<Table id="idTable" items="{/entity1}">
<columns>
<Column >
<header>
<Label design="Bold" text="Process Type"></Label>
</header>
</Column>
<Column>
<header>
<Label design="Bold" text="OptIn"></Label>
</header>
</Column>
<Column demandPopin="true" hAlign="Begin" minScreenWidth="Tablet">
<header>
<Label design="Bold" text="Frequency"></Label>
</header>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier text="{procdesc}"></ObjectIdentifier>
<ObjectIdentifier text="{optinflg}"></ObjectIdentifier>
<ObjectIdentifier text="{zfreqdesc}"></ObjectIdentifier>
<Text text="{zfreqdesc}"/>
<Select items="{/entity2}" selectedKey="{freqid}">
<!-- here's the relative dropdown binding -->
<core:Item key="{freqid}" text="{zfreqdesc}"/>
</Select>
</cells>
</ColumnListItem>
</items>
</Table>
this is the code I have in the controller.
sap.ui.define([<br> "sap/ui/core/mvc/Controller",<br> "sap/ui/model/json/JSONModel",<br> "sap/ui/model/odata/ODataModel "<br>], function (Controller, JSONModel,OData) {<br> "use strict";<br> return Controller.extend("zsdcust360test1.zsdcust360test1.controller.communicationflag", {<br> onInit: function () {<br> var oModel = var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSD_CUSTOMER_360_SRV");;<br> oModel.setData(OData);<br> this.getView().setModel(oModel);<br> }<br> });<br>});
I am having error in the Get Event in my Network tab.
Failed to resolve dependencies of 'zsdcust360test1/zsdcust360test1/controller/communicationflag.controller.js'<br> -> 'sap/ui/model/odata/ODataModel .js': failed to load 'sap/ui/model/odata/ODataModel .js' from resources/sap/ui/model/odata/ODataModel .js: script load error <br> ModuleError: Failed to resolve dependencies of 'zsdcust360test1/zsdcust360test1/controller/communicationflag.controller.js'<br> -> 'sap/ui/model/odata/ODataModel .js': failed to load 'sap/ui/model/odata/ODataModel .js' from resources/sap/ui/model/odata/ODataModel .js: script load error
Why do you have sap/ui/model/odata/ODataModel "?
First of all, there is an extra space before the closing ", which is causing an error finding the library.
Second, that library is deprecated, replaced by sap.ui.model.odata.v2.ODataModel
Third, why do you need that in your controller, your manifest.json should define the odata service and model, in your controller you just use the model's read method to bindElement to your view or any specific control.
I suggest you look at some samples or demo SAPUI5 apps, before continuing on this path.
.
You seem to have changed the code you posted above. Now it's hard to read as it's all in one line. But your error is still about the dependency define statement, with the extra space. You need to get rid of that before anything else.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.