cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5: How do I pass values to an eventhandler

sorenviggo
Participant
0 Kudos

Hello All.

I am writing my first application using the SAPUI5 toolkit. I have created a list with som detail data, and want to display a graph (using the sap.makit.* controls).

My first problem is to catch an event with some details of the record, that has been selected.

I am using code like this:

 

oImage.attachPress({currID:"EUR"}, this.onGraphRequest);

I am using an image in the list as the control for the user to press.

This part is working fine.

My eventhandler looks like this:

onGraphRequest : function(oEvent) {

     var p = oEvent.getParameter("currID");

     alert("Parm value: " + p);

}

But I am not seeing the value "EUR".

Can anybody please help ?

Søren Hansen

Accepted Solutions (1)

Accepted Solutions (1)

AndreasKunz
Advisor
Advisor
0 Kudos

Hi Søren,

custom data which is given when the event handler is registered is not mixed in to the regular parameters, but it is available as an additional second parameter of the event handler function. So you can write it like this:

  var onGraphRequest = function(oEvent, oData) {

   var p = oData.currID;

   alert("Parm value: " + p);

  }

The reason for this is that you can not only pass name-value maps but any kind of data objects, including things like functions, Controls, etc. Those could not be merged with the parameters.

Regards

Andreas

sorenviggo
Participant
0 Kudos

Thanks Andreas.

Just what I was looking for.

Søren.

Answers (0)