Search code examples
javascriptvisual-studio-lightswitchlightswitch-2013

Lightswitch HTML Client 2013 - Change Cell Color Depending Upon Cell Value in table


trying to get the background of a boolean value to change based upon true or false... trying this code and its not working with a bit field however does work on a string, any ideas guys?

if (contentItem.value && contentItem.value.substring(0, 1) == 1) {
    $(element).closest("td").css("background-color", "green");
}

and the below code changes the whole column based on the top row value only:

if (contentItem.value = 1) {
    $(element).closest("td").css("color", "green");
}
else 
{
    $(element).closest("td").css("color", "red");
}

Solution

  • got it:

    if (contentItem.value && contentItem.value == 1) {
        $(element).closest("td").css("color", "green");
    }
    else 
    {
        $(element).closest("td").css("color", "red");
    }