Page 1 of 1

Set label value for each item in a list

Posted: Sat May 10, 2014 6:21 am
by Paul King

Hi,
I am returning a list of items with latitude and longitude values. I have some javascript which calculates the distance from my current location. I have mapped the response and a couple of other fields which is working as expected.

What I need to do now is trigger that calculation for each location and set a label for each item in the list. I can't work out what coding I need for this or where I need to put it.

I thought I could maybe add it on to the javascript of another field to set the related distance label but it just overwrites the first label in the list each time.

Any help would be appreciated.
Thanks


Set label value for each item in a list

Posted: Sat May 10, 2014 11:16 am
by Igor

Hi,

You can add calculation JS code in the service mapping.
http://docs.appery.io/documentation/r...


Set label value for each item in a list

Posted: Sun May 11, 2014 12:12 am
by Paul King

Hi, thanks for the reply. I know how to do the calculation I'm just unclear as to how I set each label in the list.

So each response in my list has a lat and lng value. I want to somehow pick these two values up and drop them in to my related distance_label for each list item.

As mentioned above it just overwrites the same label. Do I need to reference an ID somehow? Is this even possible?

Thanks


Set label value for each item in a list

Posted: Mon May 12, 2014 3:19 pm
by Evgene Karachevtsev

Hello Paul,

You should map your lat and lng to local storage variable, then "add JS" with your custom calculation code to your "distance_label" as it's stated here: http://docs.appery.io/documentation/r...
In your code you have to get values from local storage variables, make calculation and return calculated value.


Set label value for each item in a list

Posted: Mon May 12, 2014 11:28 pm
by Paul King

I understand this documentation fine but what I dont understand or see any documentation on is what is mentioned above - 'add JS' to the distance label.

You can't add any javascript unless you map the component to the response. I can't map the response as it is two values, lat and lng.

I'm returning a list of locations with lat and lng, I can map them to local variables but I'm guessing the key element I am missing is as mentioned above, adding javascript to the label itself to set that labels value.

How can you set a label within a list without mapping it with a value from the response?

I appreciate your help with this.


Set label value for each item in a list

Posted: Tue May 13, 2014 3:52 pm
by Evgene Karachevtsev

Hello Paul,

You can map the two response parameter in one UI component
https://getsatisfaction.com/apperyio/...