Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Blank line in COMBOBOX  (Read 18683 times)
Candy M.
Posts: 139


« on: November 15, 2008, 12:57:30 am »

If NULL is a valid value in a combo box, we would
like the capability of having that value display at the
top of the list instead of at the bottom of the combo list.
We have complaints that the focus is at the bottom of the list
instead of the top when the combo list appears.

Is there anyway to do that and if not, could we have that
as a feature request?

Thanks,
Candy
Reuben B.
Four Js
Posts: 1113


« Reply #1 on: November 18, 2008, 02:05:22 am »

Hi Candy,

You haven't stated a version but try this code...

Code
  1. LAYOUT
  2. GRID
  3. {
  4. [f01   ]
  5. [f02   ]
  6. [f03   ]
  7. }
  8. END
  9. END
  10. ATTRIBUTES
  11. COMBOBOX f01 = formonly.combo1, NOT NULL, ITEMS=(NULL,"Y","N");
  12. COMBOBOX f02 = formonly.combo2, NOT NULL, ITEMS=((NULL,"Please select an item..."),("Y","Yes"),("N","No"));
  13. COMBOBOX f03 = formonly.combo3, NOT NULL;
Code
  1. MAIN
  2. DEFINE combo1, combo2, combo3 STRING
  3. DEFINE l_cb ui.ComboBox
  4.  
  5.   OPEN WINDOW w WITH FORM "20081118a"
  6.  
  7.   INPUT combo1, combo2, combo3 WITHOUT DEFAULTS FROM combo1, combo2, combo3
  8.      BEFORE INPUT
  9.         LET l_cb = ui.ComboBox.forName("combo3")
  10.         CALL l_cb.addItem(NULL,"Please select an item...")
  11.         CALL l_cb.addItem("Y","Yes")
  12.         CALL l_cb.addItem("N","No")
  13.  
  14.  
  15.   END INPUT
  16. END MAIN

You want NULL as a valid value so just remove the NOT NULL attribute from the .per. (I've left it in to show the functionality possible)

I couldn't find it anywhere in the release notes as to what version it was introduced but at one stage you couldn't put NULL in the ITEMS list.  If you find that, try with "" instead of NULL in the ITEMS attribute e.g. ITEMS=("","Y","N") etc

Hope that helps,

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Candy M.
Posts: 139


« Reply #2 on: November 18, 2008, 03:34:32 am »

Thanks, Reuben. 
The version is:
fglrun 2.11.03 build-1169.8

I changed your form so that combo3 allows NULLS:
--COMBOBOX f03 = formonly.combo3, NOT NULL;
COMBOBOX f03 = formonly.combo3;             

Then, I change the program so that only 2 items were added to combo3 (not the NULL item):

 LET l_cb = ui.ComboBox.forName("combo3")             
 #CALL l_cb.addItem(NULL,"Please select an item...") 
 CALL l_cb.addItem("Y","Yes")                         
 CALL l_cb.addItem("N","No")                         

Now, when you run the program, in combo3, the NULL value is at the
bottom of the list and this is what we do not want.

We are using an initializer function to populate most of our ComboBoxes
and we are not inserting a null value into the combo box and we are allowing
nulls in the field.

So, is there any way to get that NULL value at the top of the list rather than
at the bottom?

Thanks for your help.

Candy
Reuben B.
Four Js
Posts: 1113


« Reply #3 on: November 18, 2008, 03:45:49 am »

in the absence of a presentation style, what about ...

LET l_cb = ui.ComboBox.forName("combo3")             
CALL l_cb.addItem(NULL,NULL)
CALL l_cb.addItem("Y","Yes")                         
CALL l_cb.addItem("N","No")                         

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Candy M.
Posts: 139


« Reply #4 on: November 18, 2008, 05:40:27 am »

I see that when we do insert a NULL into the ComboBox, at the beginning, the NULL value is at the top.

Does that mean if nulls are allowed, you must populate the combobox with a null value?

This is not clear in the documenation.

Thanks,
Candy
Reuben B.
Four Js
Posts: 1113


« Reply #5 on: November 18, 2008, 06:42:20 am »

I see that when we do insert a NULL into the ComboBox, at the beginning, the NULL value is at the top.

Does that mean if nulls are allowed, you must populate the combobox with a null value?

...

no, if NULL's are allowed it will be added to the end of the list of items, unless there is an entry for it in the list already.  You can even put it in the middle.

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Candy M.
Posts: 139


« Reply #6 on: November 18, 2008, 08:48:08 pm »

Could I put in a request that the NULL be placed at the beginning or
add a method to ui.ComboBox where one could add an item to any
position of the list such as the beginning of the list.

Thanks,
Candy
Candy M.
Posts: 139


« Reply #7 on: November 18, 2008, 09:11:44 pm »

I changed the code so that a NULL will be put at the beginning.

However,  now on a CONSTRUCT statement if a field allows NULLS
and is QUERYEDITABLE and you insert a NULL at the top of the list,
there is also a NULL at the bottom of the list, so now there are 2 NULLS.
Should that happen?

Thanks,
Candy
Reuben B.
Four Js
Posts: 1113


« Reply #8 on: November 19, 2008, 04:32:43 am »

If you have used NULL as an first argument to addItem then the QBE string returned will be "fieldname IS NULL" if that item is selected.

If you select the NULL that is added with a CONSTRUCT (the last one) then the QBE string is effectively 1=1

If you have used cb.addItem(NULL,NULL) then this will make it confusing to the user as it will look like there are two NULL entries.  You would be better off doing cb.addItem(NULL, "No value")

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Candy M.
Posts: 139


« Reply #9 on: November 19, 2008, 05:05:35 am »

Sorry for all the questions.

That makes sense for the CONSTRUCT.

We use the same form and COMBOBOX initalizers (initializers are in the form) for INPUT/CONSTRUCT).

Is there a method that we could call which would indicate whether or not
a program is in an INPUT or CONSTRUCT? If the initializers are run when the INPUT
or CONSTRUCT statement is reached, then we could populate the COMBOBOX accordingly.

When exactly is the COMBOBOX populated?  When the form is opened or when INPUT/CONSTRUCT invoked?

Thanks again.  You've been very helpful.

Candy
Reuben B.
Four Js
Posts: 1113


« Reply #10 on: November 23, 2008, 10:35:44 pm »

...

Is there a method that we could call which would indicate whether or not
a program is in an INPUT or CONSTRUCT? If the initializers are run when the INPUT
or CONSTRUCT statement is reached, then we could populate the COMBOBOX accordingly.
...

There is a method.  In the Dom tree, if you look at the Window node you'll see a child node Dialog which will in turn have a child node DialogInfo.  That has an attribute dialogType which will have a value Input/Construct etc.

With the introduction of multi-dialogs, you will also find the dialogType attribute held on the individual field.

I used to look at the DialogInfo node when opening zoom windows to determine if they should return one value (Input), or a list of values (Construct).

Initializers are run when the window is open.  This dialogType information above should be available in the BEFORE INPUT, BEFORE CONSTRUCT so you'd have to add a call in these blocks to run the initializer function.

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines