Page 1 of 1

Get Local variable to cocatenate with Listitem text field.

Posted: Thu May 21, 2015 4:10 pm
by Frank Lichtlin

I am trying to combine 2 variables into the text field of a Listitem.

I have a model object of player that consists of name, link and number. Then I have another model playerList that is an array of type player.

I have a local storage players that is of type playerList. I have all my service response variables mapped to the local storage.

Then I am mapping my local storage name to the listitem Text field and have the following JS attached.

var playerNum = Apperyio.storage.storageVariable.get("$['players']['nmbr']");
return playerNum + " " + value;

It is not grabbing the Local Storge Variable I need for nmbr and is just giving my name mapping.

Any help would be appreciated?


Get Local variable to cocatenate with Listitem text field.

Posted: Fri May 22, 2015 5:06 pm
by Serhii Kulibaba

Hello Frank,

Please add JS to the mapping array to the list item. This code should read data from children elements and write them to the list item. E.g.:

element.find("[name=mobilelistitemName]").text(value.param1 + value.param2);

here:
mobilelistitemName - name of the list item component
value - item of the array from mapping (e.g "players")
param1/param2 - value of item's children elements (e.g. "nmbr")


Get Local variable to cocatenate with Listitem text field.

Posted: Fri May 22, 2015 8:55 pm
by Frank Lichtlin

I have tried adding this code to the mapping you suggested and no luck.

element.find("[name=mobilelistitem_11]").text(players.nmbr);

Attached are 2 screen shots of mapping.

Image

Image

Thanks!


Get Local variable to cocatenate with Listitem text field.

Posted: Mon May 25, 2015 12:18 pm
by Serhii Kulibaba

Please change
element.find("[name=mobilelistitem_11]").text(players.nmbr);
to
element.find("[name=mobilelistitem_11]").text(value.nmbr);


Get Local variable to cocatenate with Listitem text field.

Posted: Tue May 26, 2015 1:57 pm
by Frank Lichtlin

Thanks for trying to help, but that doesn't seem to work either.


Get Local variable to cocatenate with Listitem text field.

Posted: Thu May 28, 2015 11:58 pm
by Yurii Orishchuk

Hi Frank,

Please use following JS code instead of yours:

pre

element.text(value.nmbr);

/pre

Regards.