Skip to Content
0
May 27, 2018 at 06:24 PM

SAPUI5 OData binding to table

953 Views Last edit May 27, 2018 at 09:55 PM 5 rev

I try to bind campaign data from the OData service CUAN_CAMPAIGN_SRV to a TableSelectDialog element. In my view I have an Input field with input help:

<form:FormElement visible="true">
<form:label>
    <Label text="Campaign" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit"/>
</form:label>
<form:fields>
    <Input id="campaignId" type="Text" enabled="true" visible="true" width="auto" editable="true" showValueHelp="true" valueHelpOnly="true" valueHelpRequest="handleValueHelp"/>
</form:fields>

The value help calls the function handleValueHelp in my controller:

handleValueHelp: function(oController) {
     this.inputId = oController.oSource.sId;
     // create value help dialog
     if (!this._valueHelpDialog) {
         this._valueHelpDialog = sap.ui.xmlfragment(
             "my.view.Campaigns",
             this
         );
     this.getView().addDependent(this._valueHelpDialog);
     }

     // open value help dialog
     this._valueHelpDialog.open();
}

This is when my table dialog (fragment) pops up:

<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
<TableSelectDialog id="campaignSelect" title="Select campaign" items="{path:'/CampaignSet'}" growingThreshold="5">
    <columns>
        <Column>
            <Text text="Name"/>
        </Column>
        <Column>
            <Text text="ID"/>
        </Column>
        <Column>
            <Text text="Created at"/>
        </Column>
        <Column>
            <Text text="Created by"/>
        </Column>
    </columns>
    <items>
        <ColumnListItem>
            <Text text="{CampaignName}"/>
            <Text text="{CampaignId}"/>
            <Text text="{CreatedOn}"/>
            <Text text="{CreatedBy}"/>
        </ColumnListItem>
    </items>
</TableSelectDialog>

So I tried to bind the EntitySet CampaignSet from OData Service CUAN_CAMPAIGN_SRV to the table. Therefore I added this code to my init() function of the controller:

var uname = "UNAME";
var pw = "PW";

var oModel = new sap.ui.model.odata.v2.ODataModel("https://host:port/sap/opu/odata/sap/CUAN_CAMPAIGN_SRV/",
true, uname, pw);

this.getView().setModel(oModel);

The problem is: the table contains no data and this error shows up in the console:

Chrome Developer Tools Console Log

iwfnd/error_log says this:

"Invalid format (return table): Row Number 1, Property Name 'ChangedOn', Property Value '0 '"

Why does ChangedOn even matter if I don't want to bind this property?

I can call something like below directly in browser with success:

https://host:port/sap/opu/odata/sap/CUAN_CAMPAIGN_SRV/CampaignSet('100001625')/CampaignName

What do I do wrong? Thank you for every hint!

Attachments

error.png (51.0 kB)