How to: Hide fields on a Dialog Form [AX 2012]

Updated: December 29, 2011

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

This topic describes how you enable a dialog or drop dialog form to hide and then show a collection of fields and controls. To access the hidden fields, you click a button on the dialog form. You can use the hidden fields and controls to complete less common scenarios from the dialog form. To complete the following steps, you must first create the dialog or drop dialog form. For information about how to create a dialog form, see How to: Create a Dialog Form.

To add a group of hidden fields

  1. In the AOT, find the dialog form that you want to modify. Expand the form, expand Designs, expand Design, right-click the DialogContent group, click New Control, and then click Group. A group control is added to the form. Move the control to be the last control in the DialogContent group. To move the group, press ALT+UP ARROW or ALT+DOWN ARROW.

    Caution noteCaution

    If you did not use a template or the name property of the group controls were changed, you might see different names for the DialogContent or DialogCommit group controls.

  2. Right-click the group control you added and then click Properties. The property sheet for the control appears. In the property sheet, populate the following properties by using the specified values:

    Property

    Value

    AutoDeclaration

    Yes

    FrameType

    None

    Name

    MoreFields

    Visible

    No

  3. Expand the Data Source node of the form, right-click the table that contains the fields you want to add to the form, and then click Open New Window.

  4. In the AOT window that shows the table, expand Fields. Drag the field or field group you want to appear on the form onto the group control that you added earlier.

To add the button control

  1. In the AOT window that shows the form, click the group named DialogCommit. In the property sheet for the DialogCommit group, set the Column property to 2.

  2. Right-click the DialogCommit group, click New Control, and then click Button. A button control is added to the group. The button should be the first control in the group. To move the button, press ALT+UP ARROW or ALT+DOWN ARROW.

  3. Click the button. In the property sheet, populate the following properties by using the specified values:

    Property

    Value

    ButtonDisplay

    Text & Image left

    DisabledImage

    7884

    DisabledImageLocation

    EmbeddedResource

    ImageLocation

    EmbeddedResource

    Name

    moreFewerButton

    NormalImage

    7887

    Style

    Link

    Text

    To display Show more fields, select label @SYS191195.

    To display Shows fewer fields, select label @SYS191193.

To show or hide a field group

  1. Expand the button control that you added earlier, right-click Methods, click Override method, and then click clicked. The method opens in the code editor.

  2. In the code editor, add a call to a method named toggleMoreFewer. Use a reference to the current button control as a method parameter. In addition, you should add toggleMoreFewer after the call to super.

    The following code example shows how to modify the clicked method.

    void clicked()
    {
        super();
        
        element.toggleMoreFewer(this);
    }
    
  3. Add the toggleMoreFewer method to the form. Right-click the Methods node of the form, and then click New Method. A new method appears in the code editor.

  4. Specify that the method is public. In addition, change the name of the method to toggleMoreFewer and add that the method accept a FormButtonControl as a parameter. Add code that changes the Visible property of the MoreFields group that you added earlier. Also, change the image and text that appear on the button control.

    The following code example shows the toggleMoreFewer method. Notice how the method changes the visible property of the MoreFields group. Also notice how the method changes the value of the normalImage and text properties of the button control.

    public void toggleMoreFewer(FormButtonControl moreFewerButton)
    {
        element.lockWindowUpdate(true);
        
        moreFewerButton.imageLocation(2);
        
        if(MoreFields.visible())
        {
            moreFewerButton.normalImage(“7887”);
            moreFewerButton.text(‘@SYS191195’);
            
            MoreFields.visible(false);
        }
        else
        {
            moreFewerButton.normalImage(“7883”);
            moreFewerButton.text(‘@SYS191193’);
            
            MoreFields.visible(true);
        }
        
        element.lockWindowUpdate(true);
    }
    
  5. Right-click the form and then click Save.


Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.

Community Additions

ADD
Show: