Page 1 of 1

saving list data into a local storage variabile

Posted: Mon Mar 25, 2013 9:46 am
by prot984

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?


saving list data into a local storage variabile

Posted: Mon Mar 25, 2013 11:19 am
by Maryna Brodina

Hello! Working on it. I'll update


saving list data into a local storage variabile

Posted: Mon Mar 25, 2013 11:43 am
by Maryna Brodina

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


saving list data into a local storage variabile

Posted: Mon Mar 25, 2013 11:54 am
by prot984

thanks. It works. you are very kind.


saving list data into a local storage variabile

Posted: Tue Mar 26, 2013 9:07 am
by prot984

thanks very much, it works. you are very kind