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: No way to create seperate-valued Combobox in a table column?  (Read 16554 times)
Ben R.
Posts: 28


« on: May 09, 2014, 11:55:21 pm »

I have a table I would like to use a dropdown in. The idea is for the dropdown to be populated from the database with appropriate contextual choices based on other values selected in the row. For example, when describing attributes of a product, the table could look like this:

[What is the width? (prompt)] [Entry field] [Dropdown Values]
                                                                    [Inches                ]
                                                                    [Feet                    ]
                                                                    [Meters                ]
[What is the diameter?          ]Entry Field]  [Dropdown Values]
                                                                   [Millimeter              ]
                                                                   [Centimeter           ]
                                                                   [Inches                  ]

Now, when I'm using a single combobox it works fine. Here's the code I'm using to populate the combobox:

The call:

Quote
        let form_field = "sp_hlptrk.htk_description"
        let form_query = "select hgp_description ",
        "from sp_hlpgrp where hgp_level = 1 and hgp_id < 98 ",
        "order by hgp_description"
        CALL fill_combobox(form_field, form_query);

The function:

Quote
######################################################################
function fill_combobox(form_field, form_query)
######################################################################
# This function's job is to take a field and fill it using the results
# of a provided query. The query will return two values for each
# combobox entry; the actual value and the description value. The
# actual value is the value of that combobox selection and is what
# will be saved to the database if an item is selected.
#
# For example:
# "select slm_slmno, slm_name from slmmas" will display the name of
# the salesperson. If a record is added and that salesperson is
# selected from the combobox, the slm_slmno value is what will be
# saved to the record.
#
# In cases where a unique ID is not available to use for the value,
# the rowid field should be used instead to uniquely identify the row.
#
# The form_field string should be the actual table.field string, not the
# field label for the screen or data array.

  define
    form_field varchar(100),
    form_query varchar(300),
    cb ui.Combobox,
    itemValue char(50),
    itemDescription char(50)

  let cb = ui.ComboBox.forName(form_field)
  if cb is null then
    let form_field = "Form field ", form_field, " not found in current form."
    call errorlog(form_field)
    exit program
  end if

  prepare combo_results from form_query
  declare combo_cursor cursor for combo_results
  call cb.clear()
  foreach combo_cursor into itemValue, itemDescription
      CALL cb.addItem(itemValue clipped,itemDescription clipped)
  end foreach
  close combo_cursor

end function

The above call and code works perfectly when I'm attempting to have a single combobox. As far as I can tell, however, there is not a way to use distinct instances of the combobox because even if you display the dropdown multiple places on the form, it's always the same dropdown with the same values. You can't populate specific values based on the row the combobox populates.

Is there any way around this problem, or another approach I can take than the above, that will let me use this functionality? It seems like an obvious usage pattern, so I'm having trouble believing there's not a way to do this.
Reuben B.
Four Js
Posts: 965


« Reply #1 on: May 10, 2014, 04:53:55 am »

Quote
As far as I can tell, however, there is not a way to use distinct instances of the combobox because even if you display the dropdown multiple places on the form, it's always the same dropdown with the same values. You can't populate specific values based on the row the combobox populates.

Correct

Quote
Is there any way around this problem, or another approach I can take than the above, that will let me use this functionality?

Use a BUTTONEDIT + LABEL in combination with a zoom window

Quote
It seems like an obvious usage pattern, so I'm having trouble believing there's not a way to do this.

You aren't the first person to ask.  I raised the same issue as a customer when I did my first Genero migration in 2003.  Same example too, different units of measure for different types of products.  To get an understanding of difficulties involved, with the GDC in Debug mode,press Control+RIght Click and note the location of the ItemList for the ComboBox.  It is attached to the FormField node and their is one instance of the list.  For what you want, you would need many ItemLists in the AUI tree, and someway for each row to reference the appropriate ItemList.

Thinking about it, the existence of PHANTOM columns may make a suitable solution more feasible than it was previously...

Reuben

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


« Reply #2 on: May 12, 2014, 05:06:08 pm »

I take it there's no way to create dynamic form elements to have each row create a new combobox on the fly, correct? Or perhaps change the screen element type, meaning have the .per file specify the field as a normal edit box, then programmatically change it into a combobox on the back end?

I've looked for these things and didn't see anything along those lines, but just want to verify. Dynamically creating elements is a pretty standard language feature elsewhere at this point, so it's frustrating that (as far as I can tell) it doesn't exist here.
Anderson P.
Posts: 82


« Reply #3 on: May 15, 2014, 01:10:57 pm »

The problem is that when you populate the combobox of the next row with different values the values of the previous row got missing, you can still store the user's choice but it will not show in the screen.

But i was able to manage this to work out in a GWC AJAX application! In the GWC application, when you populate the combobox of a row, the others rows doesn't refresh so the value continue to show up despite it's not there anymore, all you have to do is to repopulate the combobox in the before row block... All of this considering you are making a GWC only application.
Snorri B.
Posts: 103


« Reply #4 on: May 20, 2014, 01:33:32 pm »

This issue was discussed in this thread:

https://4js.com/fjs_forum/index.php?topic=242.0
Anderson P.
Posts: 82


« Reply #5 on: May 20, 2014, 02:36:43 pm »

Hello Snorri,

Had read the topic you posted, the option of hiding some items in the combobox list is indeed interesting, considering the difficulties of different combobox contents in a input array based on the Genero BDL architecture.

Is this feature already implemented?
Snorri B.
Posts: 103


« Reply #6 on: May 20, 2014, 02:44:58 pm »

No, it's not implemented. It seems they have decided not to, at least issue #12086 has resolusion WONTFIX :(

Maybe they should reconsider....

-S
Reuben B.
Four Js
Posts: 965


« Reply #7 on: May 21, 2014, 01:30:29 am »

If it was "easy", this would probably have been done a long time ago.  (IMHO it would require modification to the AUI tree to define a Combobox value list at interface or form level, and have the combobox on each row reference a Combobox list defined at this higher level via a Phantom column)

The BUTTONEDIT + zoom window is the best way to implement this at the moment.  When this alternative has been raised before, one of the arguments against has been that this method doesn't allow you to restrict manual editing of the value in the BUTTONEDIT field.  In Genero 2.50 the NOTEDITABLE argument was introduced https://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_FSFAttributes_NOTEDITABLE.html which allows you to prevent entry in the field but still allow the button to be selected.

If you get creative with presentation styles and zoom window, you can make your list look less like a window and more like a combobox list too.  From here https://4js.com/online_documentation/fjs-fgl-manual-html/#r_fgl_presentation_styles_window_style_attributes.html consider ...
actionPanelPosition=none
menuPanelPosition=none
border=none/frame
position=field
sizable=no
statusBarType=none

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


« Reply #8 on: July 02, 2014, 07:22:00 am »

Having a zoom popup using window presentation styles looks alright, but is it possible to close the zoom window if the user takes focus away? At the moment, the only way to close the zoom window is to either double click a row "triggers ACCEPT" or to build in a button.

Ideally if I click back into the main window I want it to close the zoom window.


* popup.png (20.01 KB, 618x414 - viewed 1023 times.)
Reuben B.
Four Js
Posts: 965


« Reply #9 on: July 03, 2014, 05:42:56 am »

You probably won't be able to control the click outside zoom window behaviour so that it closes the window as that is entering the realm of the front-end OS behaviour

Looking at your screenshot, have a look at the windowOptionClose presentation style.  That controls the appearance of a little X in the top-right corner of the window that will trigger the close action, which you can use to exit the dialog without selecting a value

Reuben

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


« Reply #10 on: July 03, 2014, 06:12:27 am »


Yeah. Look at the attached image to see it with the following styles. This is probably the best solution so far:

Code
  1.    CALL lgstyle_setStyleAttribute("Window.popup", "actionPanelPosition", "none")
  2.    CALL lgstyle_setStyleAttribute("Window.popup", "windowType", "modal")
  3.    CALL lgstyle_setStyleAttribute("Window.popup", "menuPanelPosition", "none")
  4.    CALL lgstyle_setStyleAttribute("Window.popup", "forceDefaultSettings", "1")
  5.    CALL lgstyle_setStyleAttribute("Window.popup", "border", "tool")
  6.    CALL lgstyle_setStyleAttribute("Window.popup", "position", "field")
  7.    CALL lgstyle_setStyleAttribute("Window.popup", "sizable", "no")
  8.    CALL lgstyle_setStyleAttribute("Window.popup", "statusBarType", "none")
  9.    CALL lgstyle_setStyleAttribute("Window.popup", "windowOptionClose", "yes")
  10.    CALL lgstyle_setStyleAttribute("Window.popup", "windowOptionMaximize", "no")
  11.    CALL lgstyle_setStyleAttribute("Window.popup", "windowOptionMinimize", "no")
  12.    CALL lgstyle_setStyleAttribute("Window.popup", "backgroundColor", "")
  13.    CALL lgstyle_setStyleAttribute("Table.popup",  "headerHidden", "yes")
  14.    CALL lgstyle_setStyleAttribute("Table.popup",  "sizable", "no")


* popup2.png (30.24 KB, 614x477 - viewed 1039 times.)
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines