Help forum

Styling table row based on dynamic data

  • Xioteer

    2 years ago

    I am trying to create a pill with different colors based on the word that is written in the respective td.

    It could be either "Sold" or "Holding"

    How can I achieve this?
    1250152302065746000-image.png
  • Lucas G

    2 years ago

    You can use style variables or classes. Either way you'd apply them conditionally based on the cell's text
  • defaulting to white or whatever you want
  • Andreas Møller

    2 years ago

    I think classes would be the way to go
  • Xioteer

    2 years ago

    yeah that makes sense actually. I just give the class the same condition as the actual text content
  • Xioteer

    2 years ago

    That said, I am not sure whether i am doing conditionals right.

    I don't have a real condition at the moment.

    I want to check whether the value of the key is empty(null) or not.

    But it's not a real condition, right? because if the value changes, it will not really evaluate differently, but just also change the condition in the IF-Node
    1250160363400335371-image.png
  • Which will still be true?
  • Meaning, if I try to change the condition it shall check against, it just deletes everything to the left, as I put a string into the condition rather than the dynamic input
  • Lucas G

    2 years ago

    The first part needs to be Bool True/False
  • If you're using classes, then the condition would look something like this
  • 1250174383494926426-image.png
  • Change string for your item of course
  • Don't think you need the additional 'string' node
  • Xioteer

    2 years ago

    Ah So i still need to build the condition
  • Xioteer

    2 years ago

    That was just because the incorrect way of me doing it was not working without adding it. Like at all
  • Lucas G

    2 years ago

    Conditions for a class to apply are Bool as well
  • Basically, if true class is applied and if false then not applied
  • Xioteer

    2 years ago

    Yeah, just need to wrap my head around things sometimes. But I think I get it
  • Lucas G

    2 years ago

    That first field would return false if the item is null
  • Changing it to a string will just always return True
  • Xioteer

    2 years ago

    Is that how that works? So null will always opt for false
  • Basically like an "empty?"
  • Lucas G

    2 years ago

    1250175168970625045-image.png
  • That's an example of an If node
  • But this wouldn't work for a condition for a class**
  • Xioteer

    2 years ago

    if you made it true and false in the then and else it would work, right?
  • Lucas G

    2 years ago

    Right, but then it would be redundant
  • Xioteer

    2 years ago

    as it applies the class then
  • Lucas G

    2 years ago

    As you can just have the equals node
  • Xioteer

    2 years ago

    ah right. Yeah somewhere I used it correctly already
  • AY EYE

    2 years ago

    @Xioteer what are you using for your table?
  • Xioteer

    2 years ago

    uhhhhhhh... The table?
  • 🤣
  • AY EYE

    2 years ago

    LOL
  • wow i didn't even realize their was a table element ahha
  • Xioteer

    2 years ago

    Hahaha, you are killing me. I did not expect this to be a helpful answer!
  • AY EYE

    2 years ago

    hahah sometimes its just that easy
  • Xioteer

    2 years ago

    Yeah it's getting easier over time, but the heavy use of formulas remains 😄
  • IF you are altering data a lot like I do
  • AY EYE

    2 years ago

    i have no idea how to use it haha
  • Xioteer

    2 years ago

    The table?
  • AY EYE

    2 years ago

    yeah
  • Xioteer

    2 years ago

    You got a dataset from an api and need to display the data dynamically?
  • AY EYE

    2 years ago

    yes
  • Xioteer

    2 years ago

    you need to make the Table row repeat with the array of the data
    1255615532174938152-image.png
  • 1255615659778248715-image.png
  • Xioteer

    2 years ago

    Sort by is already just an extra. When you add the repeat and mark the array, you should instantly see the rows multiply
  • AY EYE

    2 years ago

    Thanks. What about the titles in your example?
  • AY EYE

    2 years ago

    i see now thanks