Forums

Change css according to database item.

rafaelscouto 09 Apr, 2019
Eg If the value is 0, change text to red.
If it is 1, change text to green

How can I make this appear in the items in a table?
healyhatman 10 Apr, 2019
In column view (as an example)
columnname:<span color="{fn:colorswitch}">{var:tablename.row.model.field}</span>
In switch
Data source: {var:tablename.row.model.otherfield}
Body:
0:red
1:green
rafaelscouto 10 Apr, 2019
Thanks for the answer.

But another question arose.

How can I use the switch to check if there is something written in the database table and get a return?

Ex.

Optional upload of files.

Check if there is any data written in the table and show the link to view the file, if not leave it blank.

Sorry my english hehe
healyhatman 11 Apr, 2019
{var.empty: Will be either true or false
rafaelscouto 11 Apr, 2019
Sorry, but I did not understand how to use it
Please detail
healyhatman 11 Apr, 2019
Answer
{var.empty:variable_name} as the data source in a switch
rafaelscouto 11 Apr, 2019
Good Morning

One more question regarding the switch in CF.

Database Ex:
db_brand: Ford, Chevrolet
db_cars: Mustang, Fusion, Camaro, Equinox ...

I have two dropdowns, in the first db_brand load, this relates to the second dropdown that loads db_cars.

Everything is working perfectly, to load the second dropdown I do a reload.

My problem is when I use the new function, Allow Additions.

When I type a new car for example, when reloading, the second dropdown goes blank, I would like it to be reloaded along a default value.

How can I do this?
healyhatman 11 Apr, 2019
You can use a * as a wildcard in your switch if you have the latest version
OR you can just use a default in your dropdown. It should look something like this

{var:mybuiltdropdownlist/apples=Apples are my favourite fruit}

This way if the mybuiltdropdownlist is empty, then a value of "apples" with the label "Apples are my favourite fruit" will be supplied instead.
rafaelscouto 11 Apr, 2019
How do I *

The other option, when reloading the second dropdown, disappears
healyhatman 11 Apr, 2019
*sigh*

You know how in a switch you have say
1:Something you want shown if it's 1
0:Something you want shown if it's 0

?

*:Something you want shown if it's anything else

Just make sure that * comes last.
rafaelscouto 12 Apr, 2019
It worked, but ...

Note: I left as follows

{var: read_data25}
* Apple = Apple

However, if I decide to choose again from the list that I already have in the database (1st dropdown) when reloading the 2nd dropdown, it has the "Apple" option and below the list the reloaded item


1st image - shows when a new item is added (typed).

2nd image - shows when I decide to choose one of the items loaded in the database. In this case, the 2nd drop-down is reloaded and with two options, the second of the list is the option that should be chosen.




rafaelscouto 12 Apr, 2019
Solved the problem




that way the correct item is now in 1st in the list
healyhatman 12 Apr, 2019
{var: read_data25}
* Apple = Apple
That's not at all what I told you to do.

{var:read_data25} would go in the dropdown options list, the *:Apple=Apple would go in the switch.
rafaelscouto 16 Apr, 2019
Even though it works that way, but whenever reload is given it returns two values,
This topic is locked and no more replies can be posted.