prot984
Posts: 0
Joined: Thu Mar 14, 2013 1:16 pm

saving list data into a local storage variabile

I have a list built by a rest which is run on a timeout.
i mapped the response to my list as follow

Image

what i would like to do is:
to store all the data i get from the response field "nChat" (mapped on the component "label_nConversazioniDestinatario" contained in the list item) and chat_id response, into a local storage variable.

in a situation like the following:

Image

I would like to save in a local storage variable a json containing the chat_id and n-chat of every list item because i need tomap this local storage variale to a REST

for example, in the case of the previous figure, I would like to obtain a local storage variabile containing:

"chat":[{"chat_id":"51-231"; "n_chat":"(6)" }, {"chat_id":"51-227"; "n_chat":"(14)" }]

Is this possible?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

saving list data into a local storage variabile

Hello! Working on it. I'll update

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

saving list data into a local storage variabile

Hello! On mapping from vettore в listitem_destinatario add JS:

codevar valuesArray;
try {
valuesArray = JSON.parse(localStorage.getItem('chat'));
if ({}.toString.call(valuesArray) !== "[object Array]") {
valuesArray = [];
}
} catch(err) {
valuesArray = [];
}
valuesArray.push({"chat_id":value['chat_id'], "n_chat":value['n_chat']});
localStorage.setItem('chat', JSON.stringify(valuesArray));/code

prot984
Posts: 0
Joined: Thu Mar 14, 2013 1:16 pm

saving list data into a local storage variabile

thanks. It works. you are very kind.

prot984
Posts: 0
Joined: Thu Mar 14, 2013 1:16 pm

saving list data into a local storage variabile

thanks very much, it works. you are very kind

Return to “Issues”