cancel
Showing results for 
Search instead for 
Did you mean: 

Change sap.m.Table cell value inside an event handler

Former Member
0 Kudos

Hello,

I have a table defined in an XML view

I need to change the value of a cell for the selected row by calling the event function in the controller

Here is my event handler code when I click the checkbox

// in the controller

validateTickets : function(oEvent){

     //Get the selected row

     var selectedItem = oEvent.getParameters().listItems[0].getBindingContext().getObject();  

//change the last cell value for the selected row.

    

  },

thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor

you are very close.

validateTickets: function(oEvent) {
     var cxt = e.getParameter('listItem').getBindingContext();
      var m = cxt.getModel();
      m.setProperty(cxt.getPath() + '/propertyName', '<yourNewValue>');
}

Please change the propertyName to the property in your object. and change <yourNewValue> too.

e.g. You object is like

{

  name: 'ABC',

  value: '10'

}

then propertyName is /value

Former Member
0 Kudos

Thank Dennis .. it is working but it is changing the value one time only.. when I click another row it does not change

I want to loop over some rows and change the value for that field

I read the following in the method description:

setProperty(sPath, oValue, oContext?, bAsyncUpdate?) : boolean

Sets a new value for the given property sPropertyName in the model without triggering a server request. This can be done by the submitChanges method.

Note: Only one entry of one collection can be updated at once. Otherwise a fireRejectChange event is fired.

any idea how to change for all selected?

saivellanki
Active Contributor
0 Kudos

Hi Tareq,

I'm not sure whether I understood your requirement properly or not.

Please check this sample - JS Bin - Table Cell Value update

Is this what you're expecting? (or) is it something else?

Regards,

Sai Vellanki.

former_member182862
Active Contributor
0 Kudos

Answers (1)

Answers (1)

Former Member
0 Kudos

Thank you Dennis and Sai..

Actually .. all of your codes are correct.. my problem was changing the value for multiple rows, it happened because I am using oData, not json.. so I created a JSON model, then copied values from oData to JSON. By binding the JSON model to the oTable I solved my problems.

thanks for your help.