Published On: March 28, 2017Categories: Technical

Dynamics AX grid control is usually bound to a data source. It has finite number of columns that display the data. However, sometimes there is a need to display the data in a matrix form. This is standard feature of the SSRS framework but it is also possible to be done on an AX form.

The Table Control is an unbound control that offers unique interaction with the user and provides functionality that is not accessible if we were to use ListView and Grid instead. With using the Table Control, we can specify the number of columns and rows we need and we will be allowed to indicate which types of controls can be used for each cell. The ability to vary the input type per cell is the most powerful feature using this control. It is done by the developer who indicates an edit control method that will return the control type needed to be displayed in that cell. This article will help you achieve just that, data represented in a Matrix form.

In this example, we show how to create a dynamic matrix for employee capacity. Each row represents an employee while each column represents a specific date. The number of columns is dynamic and based on the date range selected.
Below are presented the steps we need to follow which describe the process of using table controls:

Adding the control

Right click on the Design node of the form where the matrix needs to be displayed and choose New control >> Table. Set an appropriate name for it and set the following properties: AutoDeclaration – Yes, Width – Column width, Height – Column height


Table Control components

Insert Int field and set its AutoDeclaration property to Yes (in our case we have 2 fields since we want to display red and green color for busy and available days). Picture 1
We have also set the ColorScheme property to RGB and BackgroundColor as needed for each field, red and green respectively.

Declare your global variables in ClassDeclaration


Initialize the number of the columns (dates) and rows (users) that will be displayed on the form.


Run method

Here we populate the framework of the matrix with the dates and users.

ColorCell() method

This is the part where we decide if the cell should be colored red or green.

Override editControl() method of the Table Control

The last part is to override the editControl method and call our previous defined colorCell method for every cell.
And here is the final result:
You can also add some extras such, as filters for date selection, double-click on a particular cell to assign a new task to an employee or modify to exclude the weekend days and color them with Red if your employees don’t work during the weekend.