cancel
Showing results for 
Search instead for 
Did you mean: 

Xml View : Parameters from press function

Former Member
0 Kudos

Hi there,

my question is simple :

How can i pass some parameters into a function attached to a button in an XML View.

Here is my code :


<m:Button text="Delete" press="deleteThisData"></m:Button>

I wanted something like :


<m:Button text="Delete" press="[{0:'Data1',1:'Data2'}, deleteThisData"></m:Button>

I know how it works with an JS View but i do not know how to translate it

Can somebody explain how it works?

Regards,

Accepted Solutions (1)

Accepted Solutions (1)

AndreasKunz
Advisor
Advisor
0 Kudos

Hi Marc,

this notation is currently not supported, but thanks for the suggestion!

You can use custom data to attach information to the control and then read it in the event handler.

E.g.:

<Button text="{/actionName}" app:mydata="abc" press="doSomething"></Button>

(define the namespace "app" as well!)

and then:

doSomething: function(evt) {

    alert("data was: " + evt.getSource().data("mydata"));

}

See

http://jsbin.com/openui5-customdata-xmlview/1/edit

Regards

Andreas

Former Member
0 Kudos

Hi Andreas,

I'll try this. It seems to be a solution. Thank you.

Regards,

Marc

Answers (1)

Answers (1)

seVladimirs
Active Contributor
0 Kudos

i'm not sure what you want to do, but here is an example - you can select multiple items and delete them using "delete" button.

JS Bin - Collaborative JavaScript Debugging&lt;/title&gt; &lt;link rel=&quot;icon&quot; href=&quot;h...

Former Member
0 Kudos

Hi Vladimirs,

that is not what i want to do but i'm sure it will help me in the futur, thanks.