Changing / renaming number to text

Via my API connection I receive the status of an order:

Knipsel

But those numbers need to be shown in text, in the bootstrap table. Like this:

  • 10 - New
  • 20 - Scheduled
  • 30 - In progress
  • 35 - Paused
  • 40 - Done
  • 50 - Shipped
  • 60 - Closed
  • 70 - Cancelled

I have tried this:

status.contains(20).then("Scheduled", "")

But I seem to only be able to do that for 1 status (in this case ‘scheduled’) and not for the other statuses. Maybe I’m doing something wrong, anyone an idea?

I don’t know if will work in this case, but you can use nested ternary operators, eg:
status == 20 ? "Scheduled" : (status == 35 ? "nextStatus" : "nextTest")

Probably easier to type than enter via the UI, but there may be a better solution (if it is a solution).

1 Like

That did seem to work, thanks!

I built it out like this:

status == 20 ? "Scheduled" : (status == 40 ? "Done" : (status == 35 ? "paused" : (status == 30 ? "In Progress" : "")))

Which produced:

Knipsel

1 Like

Usually for such database structure you jave a second table containing all the statuses in your case with id’s and you just make a join to it

3 Likes

2 posts were split to a new topic: How to format currency