I am working on a HANA Native app and ran into a snag. I have rendered a SAPUI5 table bound to an odata service in my view. The problem is that I am not showing my keys in the table, so when I go to read them from my update method using oTable.getSelectedIndex and getCells, the fields with property visible: false are not available and the update fails.
View snippet for invisible columns (for keys)
oControl = new sap.ui.commons.TextField().bindProperty("value", "MEMBER_ID"); oTable.addColumn(new sap.ui.table.Column("colMEMBER_ID", {visible: false, label : new sap.ui.commons.Label({text : "MEMBER_ID"}),template : oControl, sortProperty : "MEMBER_ID", filterProperty : "MEMBER_ID", flexible : true})); oControl = new sap.ui.commons.TextField().bindProperty("value", "MEASUREMENT_TYPE_ID"); oTable.addColumn(new sap.ui.table.Column("colMEASUREMENT_TYPE_ID", {visible: false, label : new sap.ui.commons.Label({text : "MEASUREMENT_TYPE_ID"}),template : oControl,sortProperty : "MEASUREMENT_TYPE_ID",filterProperty : "MEASUREMENT_TYPE_ID", flexible : true})); oControl = new sap.ui.commons.TextField().bindProperty("value", "MEASUREMENT_NAME"); oControl.setEditable(false); oTable.addColumn(new sap.ui.table.Column("colMEASUREMENT_NAME", {label : new sap.ui.commons.Label({text : "Measurement"}),template : oControl,sortProperty : "MEASUREMENT_NAME",filterProperty : "MEASUREMENT_NAME", flexible : true}));
Controller snippet:
Update : function() { var oModel = new sap.ui.model.odata.ODataModel("../../services/member_thresholds.xsodata/", true); var oTable = sap.ui.getCore().byId("tblMemberThresholds"); var i = oTable.getSelectedIndex(); if(i>=0) { alert("Index " + i + "Selected"); var selectedRow = oTable.getRows()[i]; var oParameters = {}; oParameters.MEMBER_ID = selectedRow.getCells()[0].getValue(); oParameters.MEASUREMENT_TYPE_ID = selectedRow.getCells()[1].getValue(); oParameters.LC_MEASURE = selectedRow.getCells()[2].getValue(); oParameters.LW_MEASURE = selectedRow.getCells()[3].getValue(); oParameters.TARGET_NORMAL = selectedRow.getCells()[4].getValue(); oParameters.UC_MEASURE = selectedRow.getCells()[5].getValue(); oParameters.UW_MEASURE = selectedRow.getCells()[6].getValue(); oParameters.LL_SEND = selectedRow.getCells()[7].getValue(); oModel.setHeaders({"content-type" : "application/json;charset=utf-8"}); var Context = "/THRESHOLDS(MEMBER_ID=" + oParameters.MEMBER_ID + "MEASUREMENT_TYPE_ID = " + oParameters.MEASUREMENT_TYPE_ID + ")"; oModel.update(Context, oParameters, null, function(){ alert("Updated Successfully"); }, function(){ alert("Update Failed"); }); } else{ alert("No record selected. Select a record to update."); } },
When I call the Update method, the oParameters.MEMBER_ID = selectedRow.getCells()[0].getValue(); is pulling in the first visible column instead of my hidden column for MEMBER_ID and then I run through the array at index 6. Should I be using my model or another method to get the relevant data? I really don't need for users to see the MEMBER_ID and MEASUREMENT_TYPE_ID that I am using in the background to associate things together.
Relevant environment info:
AWS rev 68 of the HANA database on m2.2xlarge
Rev 1.0.68 of SAP HANA Studio.
SAPUI5 is version 1.16.1.
Thank you,
Jim