Kbase 16323: How to display BLANK in a COMBO-BOX using a SmartViewer?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  12/1/1999 |
|
How to display BLANK in a COMBO-BOX using a SmartViewer?
How to display BLANK in a COMBO-BOX using a SmartViewer?
--------------------------------------------------------
Users often want to display a BLANK in a COMBO-BOX. This violates
the MS-Windows standard of what a COMBO-BOX is used for. COMBO-BOXES
are generally not a good choice of visualization for fields that can
be blank.
ADDING OR UPDATING RECORDS
--------------------------
However, there are times when it is inconvenient not to be able
to display a blank in a combo-box. For instance, when ADDING a new
record using a SMARTVIEWER and a SMARTPANEL, you want the
COMBO-BOX field to be displayed as a blank or as a default value
so users will not automatically get the previous record's value
for that field. How to overcome this issue is discussed in
Knowledgebase entry 15691
"SmartViewer ADD button won't clear all widgets".
NAVIGATING THROUGH RECORDS (NO ADD OR UPDATE)
--------------------------------------------
Now, what if you don't want to UPDATE or ADD a record but
you are using a SMARTVIEWER and a PANEL to navigate through
records. For example, let's say you depict customer.sales-rep
as a combo-box. You have added a 'blank' option to the item list
of the combo-box. What happens, in this case, when you are
navigating through the list of customer records
and you happen upon a record that has no sales-rep? The default
behavior will be that the smartViewer will show the previous
record's salesrep. You can change this behavior by adding
the following code to your local-display-field
routine (after the default behavior):
if customer.sales-rep = " " or customer.sales-rep = ? then
customer.sales-rep:list-items = customer.sales-rep:list-items.
This will change the screen-value of the combo-box field to blank
if there is nothing in that field.
NOTE: A better option here is to
display a default value instead of BLANK as this violates the
MS-Windows standard for combo-boxes.
NAVIGATION VS. UPDATE PANEL
---------------------------
The solution provided above will solve the problem for you if you
are simply navigating through fields and do not want to show the
previous record's sales-rep when the current record has no sales-rep.
You may be tempted to blank out the combo-box by using the following:
customer.sales-rep:screen-value in frame {&frame-name} = " ".
This works fine if you use a Navigation Panel OR an Update Panel with
attribute instance TYPE = UPDATE (not SAVE). If the attribute
instance TYPE is set to SAVE then you will find that, each time you
blast the screen-value of the combo-box field and then try to scroll
off of that record, it will be assumed that you have UPDATED the
record and you will be prompted as to whether or not you want to
save your changes. This type of prompt would not be appropriate
when the intended behavior is to simply navigate through a list of
records. Also, the screen-value implementation wil require that
blank is a valid option in the list-items.
ANOTHER SOLUTION
----------------
The important thing to understand here is that a combo-box that
provides BLANK as a valid choice is violating the MS-Windows standard.
A better solution to the whole situation may be to choose a different
widget to visualize your field instead of a combo-box. If you
want blank to be a valid option, you may want use a selection list
and a fill-in instead of the VIEW-AS COMBO-BOX. Another solution is
to pick a default option that is non-blank.
References
----------
Notebook Entry 14024 "Is it possible to clear a combo-box?"
Notebook Entry 15691 "SmartViewer ADD button won't clear all widgets"
Progress Software Technical Support Note # 16323