0

Change the color of Number text(field) depending from the value

Hello Everyone

I want to change the color of the text (field) of my Number field depending of the added value.

For example:

I have two number fields - Number and Number1

I am using that in the Trigger after update

let AA := 'Number 1';
styled(text(AA), if AA < Number then "red" else "green" end)

but the color is not changing.

The idea is, that I have to be able to write in Number1 and the color to change automatically after adding the value.

 

It that possible at all?

18 replies

null
    • Fred
    • 4 days ago
    • Reported - view

    If you are in form view then there is no way to change the text color, even manually, in a number field.

    If you are in table view then you can add a conditional format rule to the column for Number 1.

    One solution is to add a formula field that can change colors.

    • szormpas
    • 4 days ago
    • Reported - view

    I'm not entirely sure, but it might be possible with a bit of hacking, as demonstrated in the post below:

    https://forum.ninox.com/t/g9ymv0g/field-labels-in-red-color

    • George_Tanev
    • 4 days ago
    • Reported - view

    You have give me a good idea! Thank you!
    It's there a way to change only the color of the text, because now I am changing the color of the field

     

    if Number > 'Number1' then
        styled(text("Text"), "red")
    else
        styled(text("Text"), "white")
    end

      • Fred
      • 4 days ago
      • Reported - view

      take a look at the styled() docs.

    • George_Tanev
    • 3 days ago
    • Reported - view

    Thank you every one!
    I have made it!

    But now I have another problem.
    I am using a formula to make it happend.

    Some of the text are bigger than the length of the window for the text.

    When this is a normal text I can make it on several roads.

    But - no matter what I am trying - in the formula window it's always on one line.

     

    Some ideas?

      • Ninox partner
      • RoSoft_Steven.1
      • 3 days ago
      • Reported - view

      In stead of using the styled() function, use some conditional html? You can display html in a formula field , so you can chose different styling/sizing to display your message...

      • szormpas
      • 3 days ago
      • Reported - view

       Hi,

      Another option would be to use the Floating widget to show a custom tooltip.

      • red_kite
      • 2 days ago
      • Reported - view

       you must drag on this

      • George_Tanev
      • yesterday
      • Reported - view

       Yes I have, but is not helping in that case...

      • red_kite
      • yesterday
      • Reported - view

       I dimly remember a bug in Ninox in an earlier version. Which version are you using? (Mac, iPhone, iPad, Private Cloud, etc.)

      • George_Tanev
      • yesterday
      • Reported - view

       I am using the Cloud based web version over Windows PC and Chrome browser.
      I have one on my Mac like an app as well, but it's the same.

      • red_kite
      • yesterday
      • Reported - view

      is it possible that you share a db in which there is a table with the problem area?

      • George_Tanev
      • yesterday
      • Reported - view

       Of course - where and how?

      • red_kite
      • yesterday
      • Reported - view

      here in forum

      • George_Tanev
      • yesterday
      • Reported - view

      I have send you a message

    • George_Tanev
    • 3 days ago
    • Reported - view

    Wow - thank you for your answer, but I am not so good with Ninox.

    For me even that was quite of success

    let c := Number - 'Number 2';
    if c > 0 and c <= 5 then
        styled(text("Text"), "", "green", "")
    else
        if c > 5 and c <= 8 then
            styled(text("Text"), "", "magenta", "")
        else
            if c > 8 and c < Number then
                styled(text("Text"), "", "red", "")
            else
                if c < 0 then
                    styled(text("Text"), "", "yellow", "")
                else
                    styled(text("Text"), "", "black", "")
                end
            end
        end
    end

      • red_kite
      • 3 days ago
      • Reported - view

       Hi George. Another form of conditional programming is a bit easier to read, but leads to the same result. An other thing, You need not the function text() if it is text with quotation marks.

      let c := Number - 'Number 2';;
      switch true do
      case c < 0:
          styled("Text", "", "yellow", "")
      case c > 0 and c <= 5:
          styled("Text", "", "green", "")
      case c > 5 and c <= 8:
          styled("Text", "", "magenta", "")
      case c > 8 and c < Number:
          styled("Text", "", "red", "")
      default:
          styled("Text", "", "black", "")
      end
      
      • George_Tanev
      • 2 days ago
      • Reported - view

       Hi 

      Actually this Text is just for the example.

      It's a text with more than 40 letters and that is the problem - it not fit in the window.

      And if I pull the window down - make it with more roads - the text is not jumping on the second road - like in a text box.

Content aside

  • yesterdayLast active
  • 18Replies
  • 84Views
  • 5 Following