Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3575

Re: how to update table or model on button click

$
0
0

Hi,

 

For update I need odata model right? But I am using a filter on the service url, which is working fine with Json model, when i tried with odata model it's returning error as bed request.

 

var Model1 = new sap.ui.model.json.JSONModel({            serviceUrl: "../../services/myexp.xsodata/OrderItem?$filter=AUFNR eq "+id        });
sap.ui.getCore().setModel(Model1,'myitem'); // working fine 
// i am using the below code, for update to work
var Model1 = new sap.ui.model.odata.v2.ODataModel({            serviceUrl: "../../services/myexp.xsodata/OrderItem?$filter=AUFNR eq "+id        }); // returning bed request, also adding $metadata befor the $filter(when reading)

how to ovecome this issue, as I am tring the below code to update

 

onPressAccept: function(){         // var oTable = sap.ui.getCore().byId("detail1");          var dModel = sap.ui.getCore().getModel("myitem");        //var oSelectedItem = oTable.getSelectedItem();         // var sComponent = oSelectedItem.getBindingContext("myitem").getProperty("ASTNR");          console.log(dModel);        var oEntry = {};        oEntry.ASTNR = "Approved";        dModel.update('', oEntry, null, function(){                 alert("Update successful");             },function(){                alert("Update failed");});      }  

which is not working as dModel is returing a Json model.

 

Thanks


Viewing all articles
Browse latest Browse all 3575

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>