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?

20 replies

null
    • Fred
    • 6 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
    • 6 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
    • 6 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
      • 6 days ago
      • Reported - view

      take a look at the styled() docs.

    • George_Tanev
    • 5 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
      • 5 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
      • 5 days ago
      • Reported - view

       Hi,

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

      • red_kite
      • 3 days ago
      • Reported - view

       you must drag on this

      • George_Tanev
      • 2 days ago
      • Reported - view

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

      • red_kite
      • 2 days ago
      • 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
      • 2 days ago
      • 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
      • 2 days ago
      • Reported - view

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

      • George_Tanev
      • 2 days ago
      • Reported - view

       Of course - where and how?

      • red_kite
      • 2 days ago
      • Reported - view

      here in forum

      • George_Tanev
      • 2 days ago
      • Reported - view

      I have send you a message

    • George_Tanev
    • 5 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
      • 5 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
      • 4 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.

    • John_Halls
    • yesterday
    • Reported - view

    I've been thinking bout abstracting this situation and have come up with

    let a := ["red", "orange", "green", "blue"];
    let b := [0, 5, 10];
    let j := 0;
    for i in b do
        j := j + number(Number > i)
    end;
    styled("Text", "", item(a, j), "")
    

    Anything <= 0 will be red, <=5 will be orange, <=10 will be green, and >10 will be blue.

    Regards John

    • George_Tanev
    • 15 hrs ago
    • Reported - view

    Thank you everyone!
    With the help of   I have found a solution of the case!

Content aside

  • 15 hrs agoLast active
  • 20Replies
  • 104Views
  • 6 Following