次の方法で共有


How to: Customize a List Page Grid

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

To enhance the information that you get from a list page, you can customize how data fields appear in the data grid. The following sections describe how you customize columns.

  • Using Hidden Fields with a List Page

  • Using Icons in the Data Grid

Using Hidden Fields with a List Page

To support the data needs of different user roles, you can add data fields that do not at first appear on the data grid. You can only use hidden fields together with a list page in the client. You cannot add hidden field from a list page in Enterprise Portal. A user who wants to add a hidden field can do so by using the client personalization tools. To add a hidden field, follow these steps.

To create a hidden field

  1. In the AOT, expand the Forms node, expand the list page form, expand Data Sources, expand the list page data source node, expand the Fields node, and then click the field that you want to add as a hidden field. View the properties for the selected field.

  2. Click the AllowAdd property, and set its value to Yes.

  3. Right-click the form, and then click Save.

To add the hidden field to the list page

  1. To add a hidden field, open the Microsoft Dynamics AX client, open the list page, right-click the list page, and then click Personalize.

  2. In the Personalization window, click Add fields, click the field you want to add, and then click Add. For more information about user personalization, see Enabling User Personalization of Forms.

Using Icons in the Data Grid

To quickly identify records in a list page grid that meet specified criteria, you can add a column that displays icons. Typically, the icons call attention to records that require special attention. You can only view a column with icons in a list page on the client. The icons do not appear when you view the list page in Enterprise Portal.

Note

You can also use the ImageResource property of the Window control to add an image to the data grid. However, the image is applied to all records in the grid.

The following procedures show how to add an icon to each record that meets specified criteria.

To create the data source method

  1. In the AOT, expand the Data Dictionary node, expand Tables, expand the table you use in the list page data source, right-click Methods, and then click New Method. The code editor window opens and displays the following.
       Private void method1()
        {
        }
  1. Replace private void method1() with a display method that uses the table as a parameter. For more information about display methods, see Using the display Method Modifier.

    The following code example adds a display method named creditRatingAlert to CustTable.

       display int creditRatingAlert(CustTable custTable)
        {
        }
  1. Add code to the method that determines when to display an image. The code must also return the resource ID of the image to display.

    Note

    To view the available images, display the Tools menu in the developer workspace. Click Embedded resources. The Embedded resources window displays the available images, and the resource ID of each image.

    The following code example returns the resource ID of the alert icon when the value of the customer CreditRating field is set to Poor.

       display int creditRatingAlert(CustTable custTable)
        {
            // If the value in the CreditRating field 
            // is equal to Poor, return an integer equal to the
            // resource ID of the alert symbol.
            if(custTable.CreditRating == "Poor")
            {
                return 792;
            }
           else
           {
               return 1030;
           }
        }
  1. To validate and save your code changes, click the Compile button in the code editor window. Close the code editor window.

The table method returns the resource ID of the image that you want to appear in the data grid. Now, you have to add a column where the icon appears on the data grid.

To add an icon column to a grid

  1. Expand the list page form, expand Designs, expand the Design node, right-click Grid, click New Control, and then click Window. A Window control enables you to add images to the data grid. For more information about window controls, see Overview of Form Control Types.

  2. To change the location of a column, expand the Grid, select the Window control, and then press ALT+UP ARROW or ALT+DOWN ARROW.

  3. Right-click the Window control, and then click Properties. Use the Properties window to set the following properties.

    Property

    Value

    DataMethod

    Enter the name of the method that you added to the data source table.

    For example, enter creditRatingAlert to use the method added to CustTable in the previous code example.

    DataSource

    Specify the table that contains the method that you entered in the DataMethod property.

    For example, if you entered creditRatingAlert, which is defined for CustTable, you would click CustTable.

    DisplayTarget

    Client

    Height

    16

    Name

    Specify a name that identifies the control.

    ShowLabel

    Specify whether the value in the Label property appears on the data grid. Typically, you set this property to No.

    VerticalSpacing

    0

    Width

    16

  4. Right-click the form, and then click Save.

When the list page grid loads, the data source method named in the DataMethod property is called for each record. If a record meets the criteria in the method, the specified icon appears with that record in the data grid.

See also

How to: Add Fields to the List Page Grid

How to: Add a Control to a Form

User Personalization of Forms

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