Page 1 of 1

how to make dropdown selection appear in browse or reports.

Posted: Mon Sep 14, 2020 4:55 pm
by benritter
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!

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

Posted: Mon Sep 14, 2020 9:52 pm
by Janusz
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

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

Posted: Mon Sep 14, 2020 10:05 pm
by benritter
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"?

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

Posted: Mon Sep 14, 2020 10:50 pm
by Janusz
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

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

Posted: Mon Sep 14, 2020 11:07 pm
by Janusz
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