0

Styled formula background

Having some trouble wrapping my head around how to use styled on a formula.

I have a yes/no field (Flag Account). If it is unchecked, I want the formula to just use the style I've set in the formula options. If Flag Account is checked, I want the background to be red (but the txt colour and border to stay the same).

 

Is that possible?

10 replies

null
    • Sean
    • 4 yrs ago
    • Reported - view
    • SECOS Group
    • quartz_cap
    • 4 yrs ago
    • Reported - view

    Thanks Sean. I'd seen that thread previously but looks like I needed to study it after a nights sleep so it would make sense.

    Using that formula now, but having an issue where my line break is no longer working. The formula field is 3 spaces high so I was using a line break to vertically center the text. Now, no line break.

     

    let displayText := "
    " + Name;
    let displayIcon := "";
    let displayColor := "#fff";
    let displayBackground := "#555";
    if 'Flag Account' = true then
    displayText := "
    " + Name;
    displayIcon := "warn2";
    displayBackground := "#FF0000";
    displayColor := "#fff"
    else
    if 'Flag Account' = false then
    displayText := "
    " + Name;
    displayIcon := "";
    displayBackground := "#555";
    displayColor := "#fff"
    end
    end;
    styled(displayText, displayBackground, displayColor, displayIcon)

    • Sean
    • 4 yrs ago
    • Reported - view

    Sarah, yeah you're right. The only way I know of to do what you want is to use the html() function, but it will only display properly in form view. If table view is not a priorty and you are comfortable with HTML, you might want to try that.

    • SECOS Group
    • quartz_cap
    • 4 yrs ago
    • Reported - view

    Hi Sean

     

    Familiar with HTML but a little unsure about implementing it with Ninox

     

    Would it be a matter of doing a "if 'Flag Account' = true then 

    html("
    <div style=""csshere"">"

    " + Name</div>
    ")

    • Sean
    • 4 yrs ago
    • Reported - view

    Sarah, You can do it that way or build an HTML string and assign it to a variable like...

     

    let htmlString := "HTML goes here"

     

    and add to it...

     

    htmlString := htmlString + "more HTML"

     

    until you're ready to do this

     

    html(htmlString)

     

    at the end of the formula. Also, the result won't fill the entire formula field so you can set the background of the formula field to rgb(238, 238, 238) or #EEEEEE in the "Style" setting of the formula field to match the Form background.

    • Ninox partner
    • RoSoft_Steven.1
    • 4 yrs ago
    • Reported - view

    Have you tried this already?

    styled(yourformula,if 'Flag Account' then "red" end)

    • Sean
    • 4 yrs ago
    • Reported - view

    Using that formula now, but having an issue where my line break is no longer working. The formula field is 3 spaces high so I was using a line break to vertically center the text. Now, no line break.

    • Ninox partner
    • RoSoft_Steven.1
    • 4 yrs ago
    • Reported - view

    I see, it's a strange behaviour when you use style the line break goes away. Maybe a bug? I would make 2 different formula fields and not using styled() but use a unicode icon instead for the second field.(use the style settings of the field itself to make it red) Then use the yes/no field to hide one of the two and vice versa. 
    formula 1:

    "

    " + name

    formula 2 :

    ⚠+"

    " + name

    and style this formula field in the field settings red.

    • Ninox partner
    • RoSoft_Steven.1
    • 4 yrs ago
    • Reported - view

    Oops formula 2 should be :

    "⚠

    " + name

    • Sean
    • 4 yrs ago
    • Reported - view

    Steven, Good point about using a yes/no field to alternate between the two and it would keep the display consistent whereas the HTML method would be a little different than the rest of the fields.

     

    I don't know if it's a bug or not, but it's strange that Option+Space is allowed and Option+Return isn't.

Content aside

  • 4 yrs agoLast active
  • 10Replies
  • 4106Views