11-18-2019 9:41 PM
Hi,
I have 2 tables (sap.ui) and to the first table I am binding oDataModel directly (meaning, not calling oDataModel.read method). This is how my first Table code looks like which works fine (First block of code below). But now, I am trying to assign the ODataModel's oData to a JSON Model (which I am able to) but the binding to the another table controle is not working (second & third blocks of code below). Please let me know what I am missing here.
//View.XML
<ui:Table id = "oTb1" rows = "{directBind>/DEPARTSet}">
<ui:columns>
<ui:Column>
<Label text = "Department ID" />
<ui:template>
<Text text="{directBind>SunDeptId}"/>
</ui:template>
</ui:Column>
</ui:columns>
</ui:Table>
//Contoller.js
handleLoadTab1: function(oEvent){
var oTab1 = this.getView().byId("oTb1");
this.getView().setModel(this.getOwnerComponent().getModel(), "directBind");
},
//View.XML
<ui:Table id = "oTb3" rows = "{Table3>/DEPARTSet)}">
<ui:columns>
<ui:Column>
<Label text = "Department ID" />
<ui:template>
<Text text="{Table3>SunDeptId}"/>
</ui:template>
</ui:Column>
</ui:columns>
</ui:Table>
//Controller.js
handleLoadTab3: function(oEvent){
var oTab3 = this.getView().byId("oTb3");
var oJsonMod = new sap.ui.model.json.JSONModel();
oJsonMod.setData(JSON.stringify(this.getView().getModel("directBind").oData));
oTab3.setModel(oJsonMod, "Table3");
},
01-17-2020 8:25 PM
Hi,
When using JSon model in table binding context, then you have to initialize the model directBind with an empty property:
component.js :
this.setModel(JSONModel({ DEPARTSet: [] }), "Table3");
Try this, it should work 😉
Regards,
Joseph