Hi,
I have a very simple request and I feel like I am missing one simple step. I have looked all over the web with no luck. I have created a table and bound that table to an OData service. On the press of a button, I would like to modify one column on a select number of rows and set the column equal to 1. I've correctly retrieved the indexes to the rows I would like to change, please see the code below:
onToggleRow: function() {
oTable = sap.ui.getCore().byId('tableID');
var index = oTable.getSelectedIndex();
if ( index > -1 ) {
var currentRowContext = oTable.getContextByIndex(index);
var model = oTable.getModel();
model.setRefreshAfterChange(true);
var stage = model.getProperty("STAGE", currentRowContext);
var originalStage = stage;
//After processing while loop, index will be the first non-frozen record
while ( originalStage == stage){
index = index + 1;
var loopOneRowContext = oTable.getContextByIndex(index);
stage = model.getProperty("STAGE", loopOneRowContext);
}
for (var i=0; i<index; i++){
var loopTwoRowContext = oTable.getContextByIndex(i);
var success = model.setProperty("SCH_TOOL/FROZEN_FLG", 1, loopTwoRowContext);
alert("Success = " + success + " Index = " + i );
}
model.submitChanges();
oTable.setModel(model);
}
},
My doubts start with line 24. The attribute I am trying to update is on line 26. I have received a success from the setProperty method but I do not see the data in the table update appropriately. Any help would be greatful!
For reference: The entity of the oData is SCH_TOOL and the column is FROZEN_FLG.