Deki
Posts: 0
Joined: Tue Apr 15, 2014 4:53 pm

Array mapping doesn't iterate through every object

Hi,
I have an array in localStorage and the mapping below. There is an array called 'metrics' that contains 3 objects- waist, CRP and glucose. The problem is when I want to display the 3 objects and values in them it only shows the first object, which is waist. The other two don't get displayed on the screen.
Image

When I look at the object, I see that the other two are there (CRP and glucose) but only waist shows up in the results/screen.
Image

This is the results I get. Currently the UI consists of a "grid" component and labels inside that grid.
Image

This is my DESIRED results (i.e. what I want to show)
Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Array mapping doesn't iterate through every object

Hello Deki,

Your mapping on the page for this service response is wrong. Please map your metrics to mobile grid component.

Deki
Posts: 0
Joined: Tue Apr 15, 2014 4:53 pm

Array mapping doesn't iterate through every object

The problem with that is that I get 3 different rows like the picture below. I only want 1 row with all of the results....I don't want them listed like below. Please see my screen labeled "DESIRED result" in my initial question.

Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Array mapping doesn't iterate through every object

Deki,

Mapping works only for all results.
To make it one row, please rewrite your where query, so in the result will be only one row.

Deki
Posts: 0
Joined: Tue Apr 15, 2014 4:53 pm

Array mapping doesn't iterate through every object

Evgene, I'm not sure how to rewrite my query so that the result will be one row. Can you please tell me what I need to do or give me a hint? I'm using a standard Appery database read service. Thanks

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Array mapping doesn't iterate through every object

Hi Deki,

The problem is in your object.

Unfortunatly you can not map such object to the components.

The problem is - you have an array with different data inside.

Arrays in Appery.io used to link some arrays in components(like lists or grids) in items.

Thus you need:

  1. store needed values into other object. with format:

    pre

    {
    "waist": "1",
    "crp": "2",
    "glucose": 3
    }

    /pre

  2. Then you can make direct links into your components.

    Regards.

Deki
Posts: 0
Joined: Tue Apr 15, 2014 4:53 pm

Array mapping doesn't iterate through every object

Yes, but I want to associate other fields with the 'waist', 'crp' and 'glucose'. For example I want to include thins such as 'normal' for each one of those.

For example
waist:45, normal:yes
crp:54, normal:no

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Array mapping doesn't iterate through every object

Deki,

Like Yurii said, you need to have one collection that has all columns
"waist" , "crp" , "glucose" in it and make service that collects them all in one object.
Your result should be like in Yurii example
pre{
"waist": "1",
"crp": "2",
"glucose": 3
}/pre
Then you can map it to your components without any issues.

Deki
Posts: 0
Joined: Tue Apr 15, 2014 4:53 pm

Array mapping doesn't iterate through every object

Guys, I'm sorry but I still don't understand what you mean....can you please explain it in a visual way? Some kind of image or picture?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Array mapping doesn't iterate through every object

Deki,

1) the collection creating
http://gyazo.com/6e1934a61a9c45929fac...

2) the service testing
http://gyazo.com/f5a8fdd166b4df3bea98...

3) setting page with grid and labels
http://gyazo.com/2a1a2e0de862672dae50...

4) mapping the array of objects to the elements on the page
http://gyazo.com/ce1299a436b9670ea208...

5) testing the app in a browser
http://gyazo.com/5a721c0b5f4c31d9832b...

Return to “Issues”