Page 1 of 1

How mapping Json in item list dynamically

Posted: Thu Sep 10, 2015 8:22 pm
by Bruno Grenier

Example:
jsonVariable = [
{"name":"person1", "phone":1234, "address":"address1"},
{"name":"person2", "phone":1234, "address":"address2"},
{"name":"person3", "phone":1234, "address":"address3"},
{"name":"person4", "phone":1234, "address":"address4"}....
......
{"name":"person1000", "phone":1234, "address":"address1000"},
{"name":"person5000", "phone":1234, "address":"address5000"},
]

I need to map these in ITEM LIST:
label1: name
label2: phone
label3: address

DYNAMICALLY, but in JAVASCRIPT.
The json IS NOT stored in localstorage array!
thanks


How mapping Json in item list dynamically

Posted: Thu Sep 10, 2015 8:59 pm
by Serhii Kulibaba

Hello Bruno,

Could you clarify what have you tried and what exactly does not work?
Mapping documentation: https://devcenter.appery.io/documenta...


How mapping Json in item list dynamically

Posted: Fri Sep 11, 2015 5:49 pm
by Bruno Grenier

1- I have a JSON stored as STRING on LOCALSTORAGE:
"[{"name":"person1", "phone":1234, "address":"address1"},
{"name":"person2", "phone":1234, "address":"address2"},
{"name":"person3", "phone":1234, "address":"address3"},
{"name":"person4", "phone":1234, "address":"address4"}....
......
{"name":"person1000", "phone":1234, "address":"address1000"},
{"name":"person5000", "phone":1234, "address":"address5000"},
]"

2- I will transform this STRING into JSON:

var personsString = Apperyio.storage.personsLocalStorage.get()
var personsObject = JSON.parse(personsString);

3- I need to put this JSON (personsObject) in a listview:
Image

Is a lot of "persons" in personsObject.

I want to create a listview with this, but i don't know how to MAPPING this variable (personsObject) in listview.

What do you sugest me?

Tks a lot!


How mapping Json in item list dynamically

Posted: Mon Sep 14, 2015 1:39 pm
by Serhii Kulibaba

Bruno,

You haven't parse personsLocalStorage variable. You have to:
1) Create service "persons"
2) Add it to the page
3) Add mapping from storage variable to the listitem, on it's complete event