0
votes

I created an EntityType in my gateway project. How can I bind that value to a list in SAPUI5?

<List id="id1" mode="{path: 'ODataManifestModel>EntitySetForBoolean', formatter: 'Formatter.formatForBoolean'}"" 
            items="{..}"

enter image description here

so I define in my manifest JSON the gateway service and call it ODataManifestModel. Now I'd like to bind that value from the booleanProperty and depending on that value change the mode of my list. All that is clear to me how to do but somehow I think I am not binding it correctly. Because with that I am not sure how the frontend will know that I was to use that specific property. I also tried something like this:

<List id="id1" mode="{path: 'ODataManifestModel>EntitySetForBoolean>booleanProperty', formatter: 'Formatter.formatForBoolean'}"" 
            items="{..}"

but that didn't work either, what I am doing wrong here?

3
What type of model is ODataManifestModel> sap.ui.model.json.JSONModel or sap.ui.model.odata.v2? Provide a sample data as well.O.O
it is sap.ui.model.odata.v2 sorry forgot thatMaradonaAtCoding

3 Answers

1
votes
'ODataManifestModel>EntitySetForBoolean>booleanProperty'

A few things:

  • your screenshot is probably wrong because you always need the entitySet name that can be found in the "folder" Entity Sets not the Entity Type. Although your name looks correct.
  • you have to bind one element of the entitySet (array) to the mode property specifying it with its defined key in SEGW -> your entitytype needs at least one key field. You cannot acces oData entitSet elements in an OdataModel with an index
  • you need an absolute path if you are referencing the entitySet, means after model> it must start with /. Alternatively in your controller init method after metadata loaded, bind one element to the whole view var that = this; this.getOwnerComponent().getModel().metadataLoaded().then(function() { that.getView().bindElement({path:"/EntitySetForBoolean('1234')" }); }) to use relative binding in the view (not starting with /)
  • the path within the structure uses / instead of >

Absolute Binding:

"ODataManifestModel>/EntitySetForBoolean('1234')/booleanProperty"

Or if the element is bound to the view or a parent container object in the view, you can use a relative path:

"ODataManifestModel>booleanProperty"
0
votes

mode property from ListBase can have a the following properties (None, SingleSelect, MultiSelect, Delete) and it is applied to all the list elements

0
votes

Am assuming your service looks similar to this via URL, there is no sample data provided in your question: Northwinds oData V2.

Open preview in external window

Here am using the Products Entity set.

//manifest.json
"dataSources": {
  "ODataManifestModel": {
    "uri": "path_to_your_service",
    "type": "OData",
    "settings": {
      "odataVersion": "2.0",
      "localUri": "",
      "annotations": []
    }

  },


  ..."models": {
    "ODataManifestModel": {
      "type": "sap.ui.model.odata.v2.ODataModel",
      "dataSource": "ODataManifestModel"
    },
    ..
  }
//view.xml
<mvc:View controllerName="sap.otuniyi.sample.Master" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" xmlns="sap.m" xmlns:semantic="sap.m.semantic">
  <semantic:MasterPage id="page" title="Contents">
    <semantic:content>
      <List items="{ODataManifestModel>/Products}" mode="SingleSelectMaster" noDataText="No Data Available" growing="true" growingScrollToLoad="true" selectionChange="onSelectionChange">
        <items>
          <ObjectListItem title="{ODataManifestModel>ProductName}" type="Active" icon="sap-icon://user-settings" press="onSelectionChange" />
        </items>
      </List>
    </semantic:content>
  </semantic:MasterPage>
</mvc:View>