Page 1 of 1

(RDMLX) DD bug?

Posted: Fri Apr 25, 2014 9:55 am
by stevec
If I have a value selected that is the last value in a drop down and go to that form it always opens expanded.

Happening on both ipad and android. Is this a known bug?

Re: DD bug?

Posted: Mon Apr 28, 2014 9:16 am
by MarkDuignan
This sounds a bit odd. Could you please elaborate?
- Is the drop down first element on the form.
- Are you using any focus setting operations in your program (even if they are not being used)?
- Is the #Com_Owner.isNewForm property being set to true or false when this happens?

Re: (RDMLX) DD bug?

Posted: Mon Apr 28, 2014 9:53 am
by stevec
No focus on the form anywhere except the hasfocus to select the existing drop down value being set. If any value in drop down is selected (hasfocus) it just shows the value as it should.

drop down is in a table row about 3/4 way down form/rows.

New form

Re: (RDMLX) DD bug?

Posted: Mon Apr 28, 2014 10:16 am
by MarkDuignan
Could you post the program code?

Re: (RDMLX) DD bug?

Posted: Mon Apr 28, 2014 10:38 am
by stevec
* ==================================
* Drop Down Attributes (Part of Caller Form)
* ==================================

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #LRNG_FORM)

Define_Com Class(#std_int) Name(#uDDIndex)
Define_Com Class(#std_text) Name(#uDDItemText)
Define_Com Class(#std_text) Name(#uDDItemValue)

Define_Com Class(#PRIM_BOLN) Name(#Disable)

* Soil Series
Mthroutine Name(uDdAtrVal)
Define_Map For(*Input) Class(#Lrng_form) Name(#FormView) Help('Set to #com_owner') Pass(*BY_REFERENCE)
Define_Map For(*INPUT) Class(#ADTNAM) Name(#uTable)
Define_Map For(*INPUT) Class(#ADANAM) Name(#uAttr)
Define_Map For(*INPUT) Class(#STD_STRNG) Name(#uName) Mandatory(DdAtrVal)
Define_Map For(*INPUT) Class(#STD_STRNG) Name(#uOnChange) Mandatory(DdAtrVal_Changed)
Define_Map For(*INPUT) Class(#STD_INT) Name(#uRow)
Define_Map For(*INPUT) Class(#STD_INT) Name(#uColumn)
Define_Map For(*INPUT) Class(#STD_Strng) Name(#uValue) Mandatory(' ')

#Disable := False

* Remove all pre-existing drop down values
#FormView.Set_Null Property('/Form.Fields.' + #uName + '.Item')

Case Of_Field(#uAttr)
When Value_Is(= *Blanks)
* No Attribute (Disable Value)

#uValue := *Blanks
#Disable := True

Otherwise
* Values for Attribute

#uDDIndex := 1
#FormView.Set_Dropdown Item_N(#uDDIndex) Item_Text('Select ...') Item_Value(*Blanks) Name(#uName)

#ADTNAM := #uTable
#ADANAM := #uAttr

Select Fields(#ADVVAL #ADVDES) From_File(SATRDET) With_Key(#ADTNAM #ADANAM)
#uDDIndex += 1
#uDDItemValue := #Advval
#uDDItemText := #Advdes
If Cond(#ADVVAL = #uValue)
#CSBOOL := True
Else
#CSBOOL := False
Endif
#FormView.Set_Dropdown Item_N(#uDDIndex) Item_Text(#uDDItemText) Item_Value(#uDDItemValue) Name(#uName) Hasfocus(#CSBOOL)
Endselect

Endcase

* Set the DropDown
If Cond(#uRow.IsNull)
* Table likely
If Cond(#uOnChange.IsNull)
#FormView.Set_Dropdown Value(#uValue) Name(#uName) Disabled(#Disable)
Else
#FormView.Set_Dropdown Onvaluechange(#uOnChange) Value(#uValue) Name(#uName) Disabled(#Disable)
Endif
Else
* Specific Row/Column
If Cond(#uOnChange.IsNull)
#FormView.Set_Dropdown Layout_Row(#uRow) Layout_Col(#uColumn) Value(#uValue) Name(#uName) Disabled(#Disable)
Else
#FormView.Set_Dropdown Layout_Row(#uRow) Layout_Col(#uColumn) Onvaluechange(#uOnChange) Value(#uValue) Name(#uName) Disabled(#Disable)
Endif
Endif

Endroutine

End_Com

Re: (RDMLX) DD bug?

Posted: Mon Apr 28, 2014 11:58 am
by MarkDuignan
It seems that whether the dropdown appears as expanded in your example is always controlled by the value of the last item processed by the Select loop. Could you try this modified loop?

Code: Select all

  Select Fields(#ADVVAL #ADVDES) From_File(SATRDET) With_Key(#ADTNAM #ADANAM)
    #uDDIndex += 1
    #uDDItemValue := #Advval
    #uDDItemText := #Advdes
    * Set just the properties of drop down item number #uDDIndex 
    #FormView.Set_Dropdown Item_N(#uDDIndex) Item_Text(#uDDItemText) Item_Value(#uDDItemValue) Name(#uName)
    *  Select this item’s value as the entire drop down’s current value when it matches up  
    If (#ADVVAL = #uValue)
      #FormView.Set_Dropdown Name(#uName) value(#ADVVAL)
    EndIf
  Endselect    
You normally set the currently selected drop down item by setting the Value option of the whole drop down.
To know what drop down item was selected you reverse the process and get the whole drop down’s current Value.

The HasFocus() option relates to the entire drop down - not to any individual items within it.

HasFocus() controls whether the drop down appears as expanded when it is displayed and can tell you whether the drop down was expended (ie: in focus) at the moment the user submitted a form view. You can only set HasFocus(TRUE) for a one element on a form.

Note 1: Some people also put the setting of the selected item outside and after the load loop to better handle the case where the drop down is empty and never gets any items added to it - or when no item is currently selected.

Note 2: I think that the 'no item item currently selected' situation can be handled by setting the current value to blank or to some special value you choose. eg: #FormView.Set_Dropdown value('NOE'). The get of the current value should also handle the special value 'NOE' as an indication that the user did not select anything from the drop down. Sometimes peole handle this by adding a special item to the drop down at the end that with value 'NOE' and text "Touch to select xxxxxxx ..." (or suchlike). This prompts the user to make the selection and can save having to put a label beside the drop down.

Re: (RDMLX) DD bug?

Posted: Mon Apr 28, 2014 12:42 pm
by stevec
Thanks Mark that worked!