Eric5020946
Posts: 0
Joined: Tue Sep 18, 2012 4:31 pm

how to get mapped value

REST API returns 5 json items, it is mapped to grid items and it generates properly 5 rows which display just fine

grid item is mapped as below:
api_description= label1 text
api_type = label2 text (not visible)
api_name = button text

buttons in each returned row have onclick event that triggers custom JS with alert(), this alert() should display hidden label
how do I call/target hidden label in this row to get its value?

grid is dynamically generated based on data mapping so I can't use html ID, not sure if tiggr('name') would work, if so how?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

how to get mapped value

You could read the value directly, you just need to write a jQuery select to get the right element in the DOM (with your hidden id).

Here is a simpler way, to get this working faster:

1) Use Create Local Storage Variable action on button click
2) In alert(..), simply read the value from local storage.

Eric5020946
Posts: 0
Joined: Tue Sep 18, 2012 4:31 pm

how to get mapped value

Max,

I'm not sure I follow your local storage variable solution...
Clicked button just shows me the row but doesn't give me direct access to value of hidden label in that row. All I have is "this" pointing to the button, not label.

I know I can write jquery selector but that's where it gets difficult, I need to make sure that jquery selector targets correct sibling of button wrapper. There are 2 labels (siblings) so how do I target one of them?

It gets even more complicated where there is more than 1 hidden label, in this case how do you create jquery selector with 3 siblings where 2 of them are hidden?

any thoughts? Image

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

how to get mapped value

What is the name of the component that holds the hidden label?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

how to get mapped value

Never mind, I see it in the image.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

how to get mapped value

You would do something like this on button click:

Image

instead of 'mobilelabel1', use your label name.

Then, you can run this:
code
alert (localStorage.getItem('id'));
/code

Eric5020946
Posts: 0
Joined: Tue Sep 18, 2012 4:31 pm

how to get mapped value

that would work! haven't seen TARGET COMPONENT dropdown until I clicked bind to component checkbox.. :)

thank you

Return to “Issues”