How to: Customize a List Page Grid [AX 2012]
Updated: April 15, 2011
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.
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
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.
Click the AllowAdd property, and set its value to Yes.
Right-click the form, and then click Save.
To add the hidden field to the list page
To add a hidden field, open the Microsoft Dynamics AX client, open the list page, right-click the list page, and then click Personalize.
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.
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.
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
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.
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.
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.
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.
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
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.
To change the location of a column, expand the Grid, select the Window control, and then press ALT+UP ARROW or ALT+DOWN ARROW.
Right-click the Window control, and then click Properties. Use the Properties window to set the following properties.
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.
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.
Specify a name that identifies the control.
Specify whether the value in the Label property appears on the data grid. Typically, you set this property to No.
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.
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.