2

I'm creating a read only form that will be used to display a summary of information. I need to send a parameter to the backend first before getting the information but I don't seem to see that parameter is reaching it.

It does reach the entity set but it does not show the parameter. Am I binding correctly?

This is on the controller:

onInit: function() {

    var urlEnding = "1000012233";
        var oFilterDist = new sap.ui.model.Filter("ID", 
          sap.ui.model.FilterOperator.EQ, urlEnding);
        var summaryText = this.getView().byId("summaryForm");
        summaryText.bindElement({
            path: "/SummaryScreenSet",
            filters: [oFilterDist]
        });
    }

This is on the View

<VBox class="sapUiSmallMargin" fitContainer="true" 
height="100%" width="100%" justifyContent="End" 
displayInline="true" id="leftVBox" items="{/SummaryScreenSet}">

<items>
    <f:SimpleForm editable="true" layout="ResponsiveGridLayout" id="summaryForm" columnsL="1" columnsXL="1" labelSpanL="5" title="Account Summary" labelSpanM="5">
        <f:content>
            <Label text="Status" id="__label6" design="Bold" class="sizeText"/>
            <ObjectStatus text="{CONTRACT_STATUS}" id="__status6" state="Success" class="boldText"/>
            <Label text="Permit Required" id="__label10" design="Bold" class="sizeText"/>
            <Text text="{PERMIT_REQD}" id="__text32" wrapping="false" class="sizeText"/>
            <Label text="Bill Date | Due Date" id="__label11" design="Bold" class="sizeText"/>
            <Text text="{BILL_DATE} | {DUE_DATE}" id="__text33" wrapping="false" class="sizeText"/>
            <Label text="Last Estimated Date | Next MR Date" id="__label17" design="Bold" class="sizeText"/>
            <Text text="{LAST_PAYMENT_DATE} | {nextMRDate}" id="__text39" wrapping="false" class="sizeText"/>
        </f:content>
    </f:SimpleForm>
 </items>
</VBox>
eDz
  • 87
  • 3
  • 14

1 Answers1

3

Going to assume you want a single, specific entry. In that case, what you're looking for is the Entity, not the EntitySet + filter. Coincidentally, here's one I wrote yesterday that works. I've changed the paths and ID's to reflect yours:

var form = this.getView().byId('summaryForm');

form.bindElement({
    path: "/SummaryScreenSet('" + urlEnding + "')",
    events: {
        change: function() {
            //triggers on error too I think
            form.setBusy(false);
        },
        dataRequested: function() {
            form.setBusy(true);
        }
    }
});

In that case you don't need the VBOX either, just the form. Don't forget to implement SUMMARYSCREEN_GET_ENTITY or whatever the method is on your DPC_EXT.

Edit: might want to set editable on the form to false, it shrinks the layout to suit text instead of inputs.

Jorg
  • 7,219
  • 3
  • 44
  • 65
  • Nice, but just one thing I'd like to point out..: The `path:` would become more stable if it's created [with the help of `createKey`](https://stackoverflow.com/a/47016070/5846045). – Boghyon Hoffmann Feb 22 '18 at 12:58
  • @boghyon ah nice, wasn't aware of that method. thanks for mentioning it – Jorg Feb 23 '18 at 00:06
  • thanks Jorg, but when I do this, It goes to the Get Entity and I need it to go to the Get Entity Set because It may have multiple accounts based on that 'urlEnding' – eDz Feb 27 '18 at 18:59
  • @eDz The approach is the same; use the `bindElement` on the view, or maybe the `vbox`. Next to `path` that method accepts filters, sorters, expands and all the other odata options – Jorg Feb 28 '18 at 01:05