Dynamic widget change at runtime

Author: gianni.sandigliano@unifacesolutions.com (gianni)

Hi Unifacer, we have a request from customer to dynamically map the same field to EditBox or DropDownList or RadioButton; when EditBox enduser could type in it and typed value must follow specific rules, when DropDownList or RadioButton enduser could only accept pre-defined values. As far as I know in U9.7 is NOT possible to dynamically change widget at runtime on specific conditions; the remaining solution is to manage all cases with an editbox, checking typed values against predefined rules. Any hint or suggestion from anyone? Thanks in advance! Gianni

8 Comments

  1. Hi Gianni, In a Grid you CAN dynamically change the widget type of a field. Otherwise you would have to build a workaround with three dummy fields. Paint them on top of each other and using $paintedfieldproperties ZOrder to bring the correct one to the top. Regards, Theo 


    Author: Theo Neeskens (tneeskens@itblockz.nl)
  2. Theo Neeskens said ... Paint them on top of each other ... Theo   

    ehm...I am missing something here: how can a field be directly painted on tableau or moved on tableau on top of another one? I've already looked for this explanation into Uniface Library (but with no luck...) when I've initially read about $paintedfieldproperties and its ability to manage zorder. Could you please clearify this functionality or point me to the reference documentation? A second question: in a multirow environment without grid, could each occurrence have its own zorder? In other words: $paintedfieldproperties is acting at entity level or at occurrence level? Thanks for your help. Gianni


    Author: gianni (gianni.sandigliano@unifacesolutions.com)
  3.  $paintedfieldproperties allows you to move or resize specific field widgets on a form at runtime as is documented.

    with the following exceptions:

    Labels—moving the field does not move the labe

    GUI only—it is not possible to alter the layout of fields in character-based form

    Grid widgets—fields in grid widgets cannot be moved or resized

      Anyways. You want to change widget type at runtime and AFAIK it is not posible with $properties or $fieldproperties.   Could you please clearify this part Theo ? Greetings, Sergio


    Author: fearandir (fearandir@gmail.com)
  4. fearandir said  $paintedfieldproperties allows you to move or resize specific field widgets on a form at runtime as is documented.

    with the following exceptions: Labels—moving the field does not move the label ...

    In version 9.7.01 the label property Anchor was added. If this property is enabled (Anchor=on) then labels should be moved with its associated field if it's repositioned with $paintedfieldproperties. And there's another limitation when using $paintedfieldproperties: if a form has a split bar then setting the position or size of a field using the mentioned function will not work. A possible workaround is to place a form container on the form with the split bar(s) and embed a contained form without split bars. On the contained form $paintedfieldproperties will work again. Hope this helps Daniel


    Author: diseli (daniel.iseli@uniface.com)
  5. gianni said
    Theo Neeskens said ... Paint them on top of each other ... Theo   
    ehm...I am missing something here: how can a field be directly painted on tableau or moved on tableau on top of another one? I've already looked for this explanation into Uniface Library (but with no luck...) when I've initially read about $paintedfieldproperties and its ability to manage zorder. Could you please clearify this functionality or point me to the reference documentation?

    On the tableau you have to paint the fields next to each other or just somewhere on the form. You then use $paintedfieldproperties to position the fields at the same location. With the zorder you then can specify which field should be shown on top.

    gianni said A second question: in a multirow environment without grid, could each occurrence have its own zorder? In other words: $paintedfieldproperties is acting at entity level or at occurrence level?

    A multi-occ form is a bit more tricky. With $paintedfieldproperties you can refer to a painted occurrence, but this is not necessary the (hitlist) occurrence shown on screen. E.g. say you change the size of the second painted occurrence (and at that time this is also the second occurrence in the hitlist). When you now scroll through the hitlist then you'll see that the resized field will always be on the second painted occurrence (and is therefor not associated with a specific occurrence in the hitlist). A possible workaround could be to place a form container field in the multi-occ entity and then embed a contained form (where you would use $paintedfieldproperties). Hope this helps. Daniel


    Author: diseli (daniel.iseli@uniface.com)
  6. Daniel, Painting part: OK, understood and tested! About $paintedfieldproperties and multirow entity, probably I have not phrased correctly my question, I try it again: supposing to have picted: a PK field plus 3 nonDB fields in the component FLDEDITBOX, FLDDROPDOWN, FLDRADIOBUTTON all these saving their value to DB field FLDDATABASE, I only know which field should be on top of zorder based on a PK attribute; in other words my business rule could request to have: - FLDEDITBOX on top of zorder in occurrence 1 of the hitlist - FLDDROPDOWN on top of zorder in occurrence 2 of the hitlist - FLDRADIOBUTTON on top of zorder in occurrence 3 of the hitlist when user define the PK or in a <READ> trigger $paintedfieldproperties knows what to put on top of zorder. I do not care about scrolling, Uniface should take care of it, but each occurrence needs to have its specific field on top of zorder. Hope my question is more clear now...same time I'll give it a try. Thanks, Gianni


    Author: gianni (gianni.sandigliano@unifacesolutions.com)
  7. In a multi-occurrence situation it become much more difficult indeed. Unless you convert it to a Grid. In a Grid you would not have to move or resize the field. You just paint 1 field. See the topic "Grid" in the uLibrary. It states:

    You can dynamically change the widget type of a cell representation of a field in the grid using the $fieldproperties Proc function, for example: $fieldproperties("FLD.ENT")="widgettype=PICTURE"

      If there are reasons why you cannot use a Grid and have to use a multi occurrence it may be interesting to try using a tiny contained form. Regards, Theo


    Author: Theo Neeskens (tneeskens@itblockz.nl)
  8. Hi Theo / Daniel, thanks for these valuable informations. Option to move from multi occurrence to grid is already considered from us a valid solution; a tiny contained forms is another valid option in specific situations. We are currently managing an evolution of a 20 years old uniface application: modernization tecniques like the ones mentioned will be applied wherever possible. Regards, Gianni


    Author: gianni (gianni.sandigliano@unifacesolutions.com)