Page 1 of 1

Format label of mapped service based on value

Posted: Sun Jun 15, 2014 3:02 pm
by GM

Hi,

How can I format a label in a grid that is added from a mapping service (several values are added). If the new item added is higher than zero i want it to become green and if lower than zero to become red.

I tried with below js on the mapping, but it changes all numbers to green regardless of their value

var percentchange = Appery('percentchangelabel').val();

if(percentchange < 0) {
$("[name=percentchangelabel]").css("color", "#ff0000");
} else {
$("[name=percentchangelabel]").css("color", "#03BA00");
}

thanks


Format label of mapped service based on value

Posted: Sun Jun 15, 2014 9:48 pm
by Yurii Orishchuk

Hi GM.

You have "label" component(not an "input").

Thus you need to use ".text()" instead of ".val()".

Your code should be:

precode

var percentchange = parseInt(Appery('percentchangelabel')&#46;text());

if(percentchange < 0) {
$("[name=percentchangelabel]")&#46;css("color", "#ff0000");
} else {
$("[name=percentchangelabel]")&#46;css("color", "#03BA00");
}

/code/pre

Regards.