Reset to Defaults behaviour

Started by Michael Y., October 29, 2012, 09:03:54 PM

Previous topic - Next topic

Michael Y.

I'm getting some unexpected behaviour when Resetting to Defaults in a table. I have a table with 5 columns setup in a form. In a BEFORE DIALOG, I initialize column titles and hide certain columns using the setFieldHidden() method. I also have radio buttons that utilizes an ON CHANGE. When I unhide my columns in the ON CHANGE block, and then in the table, click on "Reset to Defaults", I expect to see the same number of columns. Instead, columns become hidden again as they were when initializing my table columns in the BEFORE DIALOG. This doesn't happen if I don't try to hide columns in the BEFORE DIALOG, but ideally I would like to. Is this to be expected? Thank you.

Sebastien F.

Hello Michael,
What value are you passing to ui.Form.setFieldHidden()? This method can take 0, 1 or 2, depends on what you want to achieve.
Please provide a sample, will be easier to understand as a long text.
Seb

Michael Y.

Hello, here's a sample of the code. I've experimented with different values being passed through setFieldHidden but the behaviour stays the same.

MAIN

  DEFINE w ui.Window,
               f  ui.Form

  OPEN WINDOW w1 WITH FORM "test_table"

  LET w = ui.Window.getCurrent()
  LET f = w.getForm()

  DIALOG ATTRIBUTES(UNBUFFERED,FIELD ORDER FORM)

    INPUT BY NAME toggle
      ON CHANGE toggle

        IF toggle = 1 THEN
          CALL f.setFieldHidden("formonly.field4",1)
          CALL f.setFieldHidden("formonly.field5",1)
        ELSE
          CALL f.setFieldHidden("formonly.field4",0)
          CALL f.setFieldHidden("formonly.field5",0)
        END IF
      END INPUT

    DISPLAY ARRAY t_array TO test_array.*
    END DISPLAY

    ON ACTION cancel
      EXIT DIALOG

    ON ACTION accept
      EXIT DIALOG

    BEFORE DIALOG
      CALL f.setElementHidden("formonly.field4",1)
      CALL f.setElementHidden("formonly.field5",1)
  END DIALOG

  CLOSE WINDOW w1

END MAIN

Thanks for your input!

Sebastien F.

Can we get the form file as well?
Seb

Michael Y.

No problem,

LAYOUT
  VBOX
    GROUP

    FOLDER
      PAGE (TEXT="Table Test")
        TABLE
        {
           Col 1          Col 2             Col 3             Col 4            Col 5
          [f1              |f2                |f3                 |f4                |f5                   ]
        }
        END -- TABLE
      END -- PAGE
    END -- FOLDER

    END -- GROUP

    GROUP (TEXT="Hide/Show columns")
      GRID
      {
        [f001]
      }
      END -- GRID
    END -- GROUP
END -- LAYOUT

ATTRIBUTES

EDIT                f1 = FORMONLY.field1;
EDIT                f2 = FORMONLY.field2;
EDIT                f3 = FORMONLY.field3;
EDIT                f4 = FORMONLY.field4;
EDIT                f5 = FORMONLY.field5;

RADIOGROUP f001 = FORMONLY.toggle_table,
                  ITEMS=((1,"3 columns"),(2,"5 columns")),
                  DEFAULT=1;

END -- ATTRIBUTES

INSTRUCTIONS

  SCREEN RECORD test_array (
    FORMONLY.field1,
    FORMONLY.field2,
    FORMONLY.field3,
    FORMONLY.field4,
    FORMONLY.field5);

END -- INSTRUCTIONS


The array was defined in the 4gl outside of main, just to be clear.

Sebastien F.

I admit we have a design issue here...
We must discuss this internally, but I think that the front-end must not write hidden columns in stored settings when the hidden attribute is 1...
Please send a mail to support, with sample code attached.
Seb

Michael Y.

I will mail support about this particular issue. Thanks again for your time.