0
votes

I have a master-detail page, master list is bind with /ThingSet

<List items="{ path: '/ThingSet'}">

And ThingSet is associated with ElementSet, I can get assigned ElementSet by entity.svc/ThingSet('7d46be8a9348')/assignedElements, 7d46be8a9348 is id of one Thing.

So my questions is how to bind assigndElements to sap.m.Table in detail page?

<Table items="{ path: '/ElementSet'}">

I have tried :

1.

var oAssignModel = new sap.ui.model.odata.v2.ODataModel("destination/..../entity.svc/ThingSet('7d46be8a9348')/assignedElements");
oAssignTable.setModel(oAssignModel);

Which will failed at GET destination/..../entity.svc/ThingSet('7d46be8a9348')/assignedElements/$metadata

2.

oAssignTable.bindElement({
    path : sAssignedPath,
    model : this._oModel
});

(I can see data loaded in this way)

Not working.

3.

Use JSON Model data binding, but this will cause an empty GET request. And JSON Model data binding makes it hard to get bindingElement etc. Also, this will make table grow fail.

Code: https://stackoverflow.com/a/46638151/5238583

1

1 Answers

0
votes

Solved By

    _bindView : function (sObjectPath) {
        var oTableView = this.getView().byId("tableView"),
        oAssignTable = oTableView.byId("assignTable"),
        oItemTemplate = oTableView.byId("cli").clone(),
        sAssignedPath = sObjectPath + "/assignedElements";

        oAssignTable.bindAggregation("items", {
            path: sAssignedPath,
            template: oItemTemplate
        });
    }

This will trigger a GET request.

I found that after this._oModel.read() success, oData in oModel has been refreshed and new Elements is loaded. But data in table is still not loaded.

Thanks to https://archive.sap.com/discussions/thread/3740994, I found bindAggregation can refresh items.