Hello,
Fairly simple issue here (I think):
I have a table bound to a global model and its rows bound to "/items"
I then have a column within that table which has a valuehelpfield that pops open a dialog with a table.
This tables rows inside the dialog are bound to a temp model. Now I know this temp model has the correct data and format and I do not get a "no data" messages when I bind it's rows to the node on the temp model, and to double check that I tried binding it to an incorrect node and it did say "no data" and I tripple checked by getting the jsonstring of the model and it's exactly how it should be.
Here is the code:
oTable.addColumn(new sap.ui.table.Column({ label: new sap.ui.commons.Label({ text: "Shop", required: true }), width: "200px", template: new sap.ui.commons.ValueHelpField({ value:"{shopdesc}", valueHelpRequest: function(oEvent){ var locModel = oTable.getModel(); var rowContextPath = oEvent.getSource().getBindingContext().getPath(); var oRowObj = oEvent.getSource().getBindingContext().getObject(); var oDataOld = sap.ui.getCore().getModel().getData(); var tempModel = new myJSONModel; tempModel.setData({ shops: [] }); sap.ui.getCore().setModel(tempModel, "tempModel"); tempModel = sap.ui.getCore().getModel('tempModel'); d = tempModel.getData(); arr = d.shops; var shops = oDataOld.shops; for (var i = 0; i < shops.length; i++) { if (shops[i].area == oRowObj.area) { arr.push(shops[i]); } } var oValueHelpDialog = new sap.ui.commons.Dialog( { modal: true, title: "Select a Shop", closed: function (oEvent) { var oContext = oTableJobs.getContextByIndex(oTableJobs.getSelectedIndex()); if (oContext) { var oSel = oContext.getModel().getProperty(oContext.getPath()); locModel.setProperty(rowContextPath + "/shop", oSel["shop"]); locModel.setProperty(rowContextPath + "/shopdesc", oSel["shopdesc"]); }; }}); var oTableJobs = new sap.ui.table.Table({ visibleRowCount: 15, firstVisibleRow: 1, selectionMode: sap.ui.table.SelectionMode.Single, width : "300px" }); var oOkButton = new sap.ui.commons.Button({ text: "OK", press: function (oEvent) { oEvent.getSource().getParent().close(); }}); oTableJobs.addColumn(new sap.ui.table.Column({ label: new sap.ui.commons.Label({text: "shop"}), template: new sap.ui.commons.TextField().bindProperty("value", "shop"), editable:false, width: "100px" })); oTableJobs.addColumn(new sap.ui.table.Column({ label: new sap.ui.commons.Label({text: "Shop Description"}), template: new sap.ui.commons.TextField().bindProperty("value", "shopdesc"), editable:false, width: "300px" })); var jsonString = tempModel.getJSON(); alert(jsonString); oTableJobs.bindRows("tempModel>/shops"); oValueHelpDialog.addButton(oOkButton); oValueHelpDialog.addContent(oTableJobs); oValueHelpDialog.open(); }}) }));
var oModel = sap.ui.getCore().getModel(); oTable.setModel(oModel); oTable.bindRows("/items");
Any help would be appreciated, I can't see what's wrong here, all seems fine to me! Thanks!