0

I try to bind my Data into a List View which is shown in a Dialog. The Dialog opens through an onClick Method in the Detail View of the Master Detail View Template.

    onInit : function () {
            // Model used to manipulate control states. The chosen values make sure,
            // detail page is busy indication immediately so there is no break in
            // between the busy indication for loading the view's meta data
            var oViewModel = new JSONModel({
                busy : false,
                delay : 0,
                lineItemListTitle : this.getResourceBundle().getText("detailLineItemTableHeading")
            });

            this.getRouter().getRoute("object").attachPatternMatched(this._onObjectMatched, this);

            this.setModel(oViewModel, "detailView");

            this.getOwnerComponent().getModel().metadataLoaded().then(this._onMetadataLoaded.bind(this));


        },
    onNodeLeaveSent : function (){
            var dialog = new sap.m.Dialog({
            title: 'Invoce Documents',
            type: 'Message',
                content: new sap.m.List({
                    items:{
                        path: "{detailView>/PurchaseOrderDeliverySet}",
                        template: new sap.m.StandardListItem({
                            title: "{detailView>DNumber}",

                        })
                    }
                }),
            beginButton: new sap.m.Button({
                text: 'OK',
                press: function () {
                    dialog.close();
                }
            }),
            afterClose: function() {
                dialog.destroy();
            }
        });
        this.getView().addDependent(dialog);
        dialog.open();
        }

The list shows no Data. I don't undersand how to refer to my Entity from the Data Model correctly.

Can someone help?

Service looks like thisenter image description here

Here the metafile:

enter image description here

Jaro
  • 1,757
  • 1
  • 15
  • 36
tobzilla90
  • 607
  • 5
  • 9
  • 2
    path: "/PurchaseOrderDeliverySet", You probably need an absolute binding in items path. – futu Feb 12 '19 at 07:59
  • i tried it and get the following error in the console: List Binding is not bound against a list for /PurchaseOrderDeliverySet - Assertion failed: EntityType for path /PurchaseOrderDeliverySet could not be found! – tobzilla90 Feb 12 '19 at 08:04
  • You have this.getView().addDependent(dialog); to make your model accessible in the dialog? – futu Feb 12 '19 at 08:13
  • Yes before I call dialog.open() ... i will edit the code – tobzilla90 Feb 12 '19 at 08:17
  • Is there an `` with the `Name="PurchaseOrderDeliverySet"` in the service `$metadata`? – Boghyon Hoffmann Feb 12 '19 at 08:19
  • Yes there is a Service Entity for it. I updated the post by a screenshot of the service – tobzilla90 Feb 12 '19 at 08:26
  • 1
    Is the default model referred in `path: ...` an ODataModel in the first place? Could be a [similar issue as this one](https://stackoverflow.com/q/53866169/5846045) – Boghyon Hoffmann Feb 12 '19 at 08:31
  • I think you are right but i cannot get it to work can you take another look, i will update the code again... thank you – tobzilla90 Feb 12 '19 at 08:42
  • Now you're telling the framework to look for the path `PurchaseOrderDeliverySet` in the `detailView` model, which can't be found obviously. Try to remove the model name from `path: "{detailView>/PurchaseOrderDeliverySet}"` as well as from `title: "{detailView>DNumber}"` to indicate that the data should be retrieved from the default model instead of the view model. – Boghyon Hoffmann Feb 12 '19 at 09:07
  • Okay but if i get rid of it it is the same code as before... so how to get it running? – tobzilla90 Feb 12 '19 at 09:16
  • your screenshot does not show ...PURCHASE_SRV/$metadata result. I assume your odata definition is incorrect, referring to this 'EntityType for path /PurchaseOrderDeliverySet could not be found!' error message from above. – futu Feb 12 '19 at 09:34
  • Sorry, added the metafile to the post ... – tobzilla90 Feb 12 '19 at 09:50

2 Answers2

0

It is getting messy in comments, so I write it as an answer:

Your initial coding should work with an absolute binding (leading /) in item. See SAP Coding Example

path: "/PurchaseOrderDeliverySet"
  • if your service returns data in the browser via the raw odata url
  • if your OData model is your default model without a name (lookup in manifest.json)

But looking at your business logic you probably want to show all deliveries for the selected (in master view) and shown (in detail view) purchase order.

Element Binding in DetailView: /PurchaseOrder('1234')

So you want to bind against the Navigation Property of the PurchaseOrder Entity to the PurchaseOrderDelivery Entites. The Associations are visible in the metadata, the navigation property not. I assume it exists and name it here POtoPODeliveries

In OData /PurchaseOrder('1234')/POtoPODeliveries returning an array PurchaseOrderDeliverSet for this particular PurchaseOrder 1234 (if implemented correctly).

The path of the item property now needs a relative binding to the DetailView's existing Element Binding

path: "POtoPODeliveries"

The bindings within the template property are always relative to the items binding and only need a model name if the item binding has a model name.

futu
  • 868
  • 6
  • 12
0

I believe that somehow the model created on OnInit (in your example, oViewModel) its not being accessed by the "children" (in your case the dialog) of your view.

Try these>

Or

  • Declare your model on the manifest.json so it is instanciated automatically by sapui5. That way you can try to access it anywhere on your app:

    enter image description here

enter image description here

Geraldo Megale
  • 363
  • 1
  • 10
  • oViewModel is a "local helper model" changed only by its controller. These values are stored in a model to be easily referenced in the view, but it holds no real data sets, merely flags and switches for minor convience functions and can be considered as optionally. – futu Feb 13 '19 at 12:04
  • There is one common scenario that makes sense to get real data set on a JSONMODEL: If the backend your are consuming is not a ODATA one. – Geraldo Megale Feb 14 '19 at 00:30