-3

Because of problems with reading all lines of a UI5 common table and the getModel() method from table offers a model.

I thought I could use a JSONModel instead of my ODataModel, the problem now is how to get the ODataModel to the JSONModel.
Because JSON offers some Two Way Binding options which should be helpful.

I tried to read some set and bind it to the JSONModel, the problem is that I couldn't bind the new model two the view because it doesn't offer some set.

Here is a snippet of my code. Hopefully this should be easier too fix as the reading all table rows:

//Erstellung des Modells
var oModel2 = new sap.ui.model.odata.ODataModel(url, true, username, password);
var oModel = new JSONModel(jQuery.sap.getModulePath("QuickStartApplication.model", "/Search.json"));

oModel2.setSizeLimit(8000000);
var pspJSONModel = new sap.ui.model.json.JSONModel();
var oODataJSONModelDLSet = new sap.ui.model.json.JSONModel();
var oODataJSONModelProjectSet = new sap.ui.model.json.JSONModel();
var oODataJSONModelPSPset = new sap.ui.model.json.JSONModel();
var debitorJSONModel = new sap.ui.model.json.JSONModel();
this.getView().setModel(pspJSONModel, "jsonmodel2");
this.getView().setModel(oODataJSONModelDLSet, "jsonmodel");
this.getView().setModel(oODataJSONModelProjectSet, "jsonmodel3");
this.getView().setModel(oODataJSONModelPSPset, "jsonmodel4");
this.getView().setModel(debitorJSONModel, "jsonmodel5");
this.getView().setModel(oModel, "saves");
// etc

oModel2.read("/SEARCH_DLSet", null, null, false, function (oData, oResponse) {
    oODataJSONModelDLSet.setData({ DLSet: oData });
});
oModel2.read("/Search_ProjectsSet", null, null, false, function (oData, oResponse) {
    oODataJSONModelProjectSet.setData({ ProjectSet: oData });
});
oModel2.read("/SEARCH_PSPSet", null, null, false, function (oData, oResponse) {
    oODataJSONModelPSPset.setData({ PSPset: oData });
});
oModel2.read("/DebitorSet", null, null, false, function (oData, oResponse) {
    debitorJSONModel.setData({ DebitorSet: oData });
});
oModel2.read("/PSPSet", null, null, false, function (oData, oResponse) {
    pspJSONModel.setData({ Pspset2: oData });
});
var json1 = pspJSONModel.getJSON();
var json2 = oODataJSONModelDLSet.getJSON();

I saw that the table row binding has found the correct length of the data that it should get but the column binding won't work. Here is a code snippet of row binding and then the column

                            <Text text="PSP(A-Nr.)" class="sapUiResponsiveMargin" ></Text>
                            <ComboBox id="combo1"  items="{path: 'jsonmodel2>/Pspset2/results'}">
                                <core:Item key="{jsonmodel2>Psp}" text="{jsonmodel2>Psp}" />
                            </ComboBox>         

                            <Text text="Abrechnungsstatus" class="sapUiResponsiveMargin" ></Text>
                            <ComboBox id="Abrechnungsstatus"></ComboBox>                    
                        </l:VerticalLayout>
                    </l:HorizontalLayout>
                </l:VerticalLayout> 
             </l:HorizontalLayout> 
             </ScrollContainer> 
         </Panel>   
     <Panel visible="false" height="80%" width="98%" id="__layout15" class="__layout5">
<Button text="Edit" id="edit" type="Transparent" class="buttons" press="onEditRow"> </Button>
        <t:Table class="table0" id="table1" selectionMode="MultiToggle" rows="{jsonmodel>/DLSet/results}">
            <t:columns>
                <t:Column class="columns"  width="105px">
                    <Label text="Kontrakt Nr." id="lKontrakt" >
                    </Label>    
                    <t:template>
                        <commons:TextField id="Kontrakt" editable="false" value="{jsonmodel>KontraktNr}" ></commons:TextField>
                    </t:template>                   
                </t:Column>

Also my two OData Models got on first binding property the set name under sPath but my new one won't get this property.

Here are some Screens from debugging:

OModel 1 with first property of binding

New Model with first property of binding but no right path

Update examples of how the json Result looks like:
PSPSet:

{
  "Pspset2": {
    "results": [
      {
        "__metadata": {
          "id": "http://hvw-sapdev01.oms-sap.omnisys.de:8000/sap/opu/odata/SAP/Z_TBRKNPRO_SEARCH_DL_SRV/PSPSet('00014158001')",
          "uri": "http://hvw-sapdev01.oms-sap.omnisys.de:8000/sap/opu/odata/SAP/Z_TBRKNPRO_SEARCH_DL_SRV/PSPSet('00014158001')",
          "type": "Z_TBRKNPRO_SEARCH_DL_SRV.PSP"
        },
        "Psp": "00014158001"
      },
      {
        "__metadata": {
          "id": "http://hvw-sapdev01.oms-sap.omnisys.de:8000/sap/opu/odata/SAP/Z_TBRKNPRO_SEARCH_DL_SRV/PSPSet('00030173001')",
          "uri": "http://hvw-sapdev01.oms-sap.omnisys.de:8000/sap/opu/odata/SAP/Z_TBRKNPRO_SEARCH_DL_SRV/PSPSet('00030173001')",
          "type": "Z_TBRKNPRO_SEARCH_DL_SRV.PSP"
        },
        "Psp": "00030173001"
      }
    ]
  }
}

And DLSet:

{
  "DLSet": {
    "results": [
      {
        "__metadata": {
          "id": "http://hvw-sapdev01.oms-sap.omnisys.de:8000/sap/opu/odata/SAP/Z_TBRKNPRO_SEARCH_DL_SRV/SEARCH_DLSet(9168)",
          "uri": "http://hvw-sapdev01.oms-sap.omnisys.de:8000/sap/opu/odata/SAP/Z_TBRKNPRO_SEARCH_DL_SRV/SEARCH_DLSet(9168)",
          "type": "Z_TBRKNPRO_SEARCH_DL_SRV.SEARCH_DL"
        },
        "Abrechungsstatus": "",
        "Contractnr": "",
        "DatumHigh": "",
        "DatumLow": "",
        "Login": "",
        "Mandant": "",
        "Mitarbeiter": "",
        "Name": "",
        "Psp": "",
        "Client": "001",
        "Id": 9168,
        "Impdate": "",
        "Ldatum": "20130705",
        "Lperiode": "",
        "PersNr": "49056462",
        "PersName": "J",
        "PersGrade": "",
        "LocalGradeKey": "",
        "LocalGradeDesc": "",
        "PersKstN": "",
        "PersKstB": "",
        "AufKstNr": "",
        "AufKstBe": "",
        "AufNr": "",
        "AufBez": "",
        "Bemerkung": "",
        "DebitorId": "0000037503",
        "DebitorBez": "G",
        "ProdCodeNr": "T130",
        "ProdCodeBez": "Allg. Steuerberatung von Unternehmen",
        "IndustCodeNr": "99999",
        "IndustCodeBez": "H",
        "ArbZ": "5.0000000000000000E-01",
        "ScaleRate": "280.0000",
        "MarketRate": "280.0000",
        "ScaleValue": "0.0000",
        "CostRate": "0.0000",
        "CukyCostRt": "",
        "Fakturiert": "",
        "FakeLdate": "",
        "Confidential": "",
        "KontraktNr": "5000059735",
        "PrctrHead": "",
        "Honorar": "140.0000",
        "Kosten": "140.0000",
        "SatzNeu": "280.0000",
        "HonorarNeu": "140.0000"
      },
      {
        "__metadata": {}
      }
    ]
  }
}
1
  • 2
    Please do not vandalize your posts. By posting on the Stack Exchange network, you've granted a non-revocable right for SE to distribute that content (under the CC-BY-SA 3.0 license). By SE policy, any vandalism will be reverted and subsequent attempts will get you banned. If you would like to disassociate this post from your account, see What is the proper route for a disassociation request? Dec 22, 2018 at 4:52

2 Answers 2

1

As your code seems really unclear, here's a pointer on how you could implement it:

You read the OData response into a JSONModel:

var oModel2 = new sap.ui.odata.ODataModel();
var oODataJSONModelDLSet = new sap.ui.json.JSONModel();

this.getView().setModel(oODataJSONModelDLSet, "jsonmodel");

// etc

oModel2.read("/SEARCH_DLSet" + filterString, null, null, false, function (oData, oResponse) {
    oODataJSONModelDLSet.setData({ DLSet: oData });
});

...you then bind to your view:

<t:Table rows="{jsonmodel>/DLSet/results}">
    <t:columns>
        <t:Column>
            <Label text="Kontrakt Nr." /> 
            <t:template >
                <commons:TextField value="{jsonmodel>KontraktNr}" />
            </t:template>                   
        </t:Column>

EDIT: Updated answer based on updated question

13
  • so i tried too get my code a little bit cleare so i need then to read all sets to my JSONModel i think so so i did it like this
    – DLÜCKEL
    Mar 30, 2016 at 12:18
  • and bindet it like you told me the problem if got to is that only the psp binding is working ok i know why sry thats my fault only one odata for each set
    – DLÜCKEL
    Mar 30, 2016 at 12:25
  • 1
    There will be a degraded performance if your have tens of thousands of records, but other than that, it should just work. aBindings should not contain the data, just the binding info I think. The model's data is in the oData property
    – Qualiture
    Mar 30, 2016 at 14:18
  • yeah that the problem the data is in oData but aBindings just don't get the Complete Binding informations but i can't change this manualy so i don't know if this is a Bug or i just doing something wrong I created every thing the same ways and bind it the same way why i get not the same way the bindings.
    – DLÜCKEL
    Mar 30, 2016 at 14:27
  • Really hard to tell.. I have never ever seen it fail, so there must be something in your code. Can you provide a simplified jsbin or plnkr example?
    – Qualiture
    Mar 30, 2016 at 14:37
0

First: did you properly attached your JSONModel to your view, using the 'jsonmodel' name (because you refer to it in your table's binding)

Then, have you checked the structure of the oData object ? you are asking something like:

{ oData : { results : [... ] } }

Finally in the text field you do not reference 'jsonmodel' again, you should put {jsonmodel>KontraktNr} instead of just {KontraktNr}

1
  • yeah i am named the model when i am binding the model too the table, Too second under {oData : { reuslts : { [...][...][...]}} the results of the request are fitted in. And yeah I did this before another on in scn told me that i should try it without but yeah i thought before i did this it couldn't been alright.
    – DLÜCKEL
    Mar 29, 2016 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.