how to make dropdown selection appear in browse or reports.

Questions related to using nuBuilder Forte.

how to make dropdown selection appear in browse or reports.

Postby benritter » Tue Sep 15, 2020 12:25 am

Hello, I have several dropdown/multiselect objects in my project. In all of the reports or browse forms I have made, the value from the select objects displays as their "option" number. For example, One of my dropdown objects has a list of cities. The user selects their city when they enter and save their information. When I access that field in a browse form or report, instead of seeing the name of the city, I see the related number that is stored in the database. Can I change the setting to display the words instead?
Thanks!
benritter
 
Posts: 22
Joined: Thu Aug 27, 2020 6:08 am

Re: how to make dropdown selection appear in browse or repor

Postby Janusz » Tue Sep 15, 2020 5:22 am

Hi,
For select you define a pair composed of ID and Displayed Value.
If you want them to be the same - define the same value for both - you can define in Select/Sql for example:
Code: Select all
a1|a1|b2|b2|c1|c1

or with myql
Code: Select all
SELECT
    ofs_description, ofs_description
FROM
    Oferta_status
Janusz
 
Posts: 333
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: how to make dropdown selection appear in browse or repor

Postby benritter » Tue Sep 15, 2020 5:35 am

Thanks Janusz,
That works. I had all the pairs defined as 0|thing1|1|thing2|2|thing3 etc. because I thought the numbers were necessary for the code to execute properly.
Having the pairs matched makes me wonder, why does it need a "pair" at all? and not simply a list. In other words, why does it need a separate "option id" and "display id"?
benritter
 
Posts: 22
Joined: Thu Aug 27, 2020 6:08 am

Re: how to make dropdown selection appear in browse or repor

Postby Janusz » Tue Sep 15, 2020 6:20 am

normally it gives better flexibility you can use (short ID) and more descriptive label - and probably due to that it was done like that
from practical point of view if I use the same select in different forms I create small sql table with phpmyadmin and in the select I use for example:
Code: Select all
SELECT
    ofe_descr, ofe_descr
FROM
    Oferta

because in case of any changes or extention you change it just in one place only.

If you prefer to store ID and make much more descriptive label you can use something like that in select (just one example from my application):
Code: Select all
SELECT * FROM
(SELECT raports_id,
CONCAT(rap_type,REPLACE(REPLACE(rap_frozen,1,'✔ '),0,'    '),rap_number) AS raporty
FROM raports
WHERE rap_type IS NOT null
ORDER BY rap_updated_on DESC
LIMIT 200)
AS tab3
ORDER BY raporty ASC
Janusz
 
Posts: 333
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: how to make dropdown selection appear in browse or repor

Postby Janusz » Tue Sep 15, 2020 6:37 am

and to add - in Browse/Display form definition you can use as well any sql statement like for example:
Code: Select all
REPLACE(REPLACE(REPLACE(rej_appr,1,'✔'),2,'❌'),0,'')

to make your browse form more readable or to better display some data
Janusz
 
Posts: 333
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland


Return to General