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

get label.text() value for all list items in a list built by using a Rest service

i'm building a kind of chat project
I have a list dinamically built by using a Rest service.Each list item contains a grid with labels.
The rest is called (by a timout every x seconds).
One of the data i get from the rest service is the user status (online, offline etc.) and i mapped this data to a label [label_status] in the grid contained in the list item component.
I would like to change the text (online, offline) with an icon. and it should happen everytime the rest is run by the timeout

I tried by adding all the icons (set to invisible) in the grid cell where the [label_status] is.
and i would like to run a js like

if (Tiggr('label_status').text() == "online") {
Tiggr('ico_online').show();
}

to test if it is possible in the mapping page of my rest service I added a JS to the label_status component (label_status)
but what i get is

Image

How can i solve my problem????????

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

get label.text() value for all list items in a list built by using a Rest service

I shared my project with a href="mailto:support@tiggzi.com" rel="nofollow"support@tiggzi.com/a

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

get label.text() value for all list items in a list built by using a Rest service

You put alert in mapping and trying to show in alert value which is not set yet -that's why you see empty brackets. You can put alert(value) to see what you get there.

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

get label.text() value for all list items in a list built by using a Rest service

I tested by adding
if (value == "n") {Tiggzi('ico_offline').show()}
and it works almost correctly.
The only problem is that on the first run of the Rest Service the first list item is without any icon while from the second run every icons is showed

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

get label.text() value for all list items in a list built by using a Rest service

it seems that if i add the JS in the mapping area in the label component conteined in list Item

if (value == "n") {Tiggzi('ico_offline').show()} or
if (value == "SI") {Tiggzi('labelMessaggioInviato').css('color', '#1d650e')}

Image

on the first run of the Rest Service the color change affects almost every itemes except the first
on the second run the color change affects every list item

should i add some code to the listItem component????

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

get label.text() value for all list items in a list built by using a Rest service

Hi,

You use mapping, so components on the page are duplicated. As the result, there are several components with the same name on page.

That is why using Tiggzi('labelMessaggioInviato') is incorrect. You can use the following code in mapping:

codeelement.closest("[name=listitem_msgInviati]").find(["name=labelMessaggioInviato"])
/code

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

get label.text() value for all list items in a list built by using a Rest service

I'm sorry but i'm not sure i undrestood.

may problem is: I have 2 list that are built by calling 2 Rest service with a timout.
in each list item there is a grid with some labels.
i would like:
(1) first list: one of the data i get from the rest is Status (online, offline). and i would like to show the online icon if the label_status is = "online" an hide the offline icon and viceversa everytime the rest servis is run.

(2) second list: one of the data i get from the rest is colered (true, false), and if colored is = true I would like to change the color of the text of another label (labelMessaggioInviato) contained in the grid emedded in the list item

Questions:
what kind of JS i should insert to achieve my goals?
where should i run these JS???

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

get label.text() value for all list items in a list built by using a Rest service

Hello!

1) To change visibility of components depending on Rest Service you would need to map response parameter which is storing status to Visible image property, click Add button and insert next code:

codeif(value == "online") {
return "true&quot
}
else {
return "false&quot
}/code

Then image will be visible if response parameter has "online" value.

2) If we understand you correctly you would need to map response parameter "colered" to that Label which color you want to change, click "Add JS" button and insert next code:

codeif(value==true) {
element.css('color', '#1d650e');
}

return value;/code

element is the component which you map and it's color will change depending on value in mapping

Return to “Issues”