Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: how to update table or model on button click

$
0
0

Do you wanna do changes for all lines displayed in your table or do you wanna do changes for only a specific line?

 

In general you have to add a handler method for the press event of your button, e.g.

new sap.m.Button({  text: "Accept",  type: sap.m.ButtonType.Accept, press: "onPressAccept"})

In your controller you have to define that method.

 

In case you wanna do changes for all lines, you can access the table lines, e.g. like following

onPressAccept: function(oEvent){  var oTable = this.getView().byId("idOfYourTable");  var aItems = oTable.getItems();  aItems.forEach(function(oItem){    var oCtx = oItem.getBindingContext("myItem");    // dummy determination of Component information     var sComponent = oCtx.getProperty("Component");        // do e.g. update    // ...  });
}

For several entries you can use the batch mode of the ODataModel instead of updating each single records by its own.

 

In case you just wanna update a specific record you have to introduce a selection mode for the table. For sap.m.Table it is defined via property "mode" which can have "Single" as value which defines that just a single record can be selected. To access a selected record in the press handler method, you can call method getSelectedItem for your table.

onPressAccept: function(oEvent){  var oTable = this.getView().byId("idOfYourTable");  var oSelectedItem = oTable.getSelectedItem();  var sComponent = oSelectedItem.getBindingContext("myItem").getProperty("Component");
}

 

In general I would recommend you to have a look on the UI5 developer guide (at least the essentials) to understand what you are doing.

 

Regards, Florian


Viewing all articles
Browse latest Browse all 9165

Trending Articles



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