Share via


Dynamics AX 2012: How Wide is my Grid Column?

So you want to know about column sizing?

You'd think the sizing of a column in a grid would be a fairly straightforward task. In Dynamics AX2012... it is, as you shouldn't ever have to care as the Dynamics framework implements a pretty sophisticated algorithm to attempt to size the columns in the grid to effectively show your data. If you're reading this blog post you are obviously among a very few select human beings.

1) You are enough of a nerd that you want to know how Dynamics AX sizes its columns, only because you want to know all there is to know about Dynamics AX.

2) You stumbled upon this post looking for something else, and you aren't sure why you are still reading this.

3) You are a friend or family member and you are being polite and reading this because I sent you a link.

4) You actually have a problem to solve and can't understand why your changes aren't effective in sizing the grid columns.

 

If number 1 or 4 apply to you, continue reading, otherwise you have my permission to go walk the dog.

 

How does it work?

Both the developer/customizer and the end user have the power to explicitly size columns, but without intervention, the Dynamics AX grid control will actually inspect the data that it is about to show, and size the column to make sure that most/all of the data is visible. That's right... the grid will size columns dynamically depending upon the data. If that wasn't enough... if the size of the column isn't wide enough to show the corresponding label... then it will also take that into account. For example if all of the data in a column were a Two -Character US State abbreviation such as "CA" then the grid would initially set it's size to 2 characters wide. However, it also looks at the column label... say for example "State." The grid also accommodates the label and ensures that the grid column width is wide enough to show the label as well. So, in this case the width of a "state" column would be 5 characters wide. As a developer, if you are authoring a control, you can override the algorithm that looks at the data by setting an explicit size on the EDT or Control associated with the data. However, min/max and label will still govern the size. That is, you cannot set an explicit width of 3 characters for a state and expect it to be 3 characters wide, as the grid layout engine will apply the min/max/label rule and make the column 5 characters wide. The assumption is that there isn't a scenario, where by default you want to show a column that is 0 characters wide, nor wider than the maximum width nor one with an truncated label. In the end, the end user is the one who may overrule all. It's his screen, he gets to decide if he needs a description column 20 characters wide, 40 characters wide or 80 characters wide. He does so by simply and interactively sizing the column and it will be "remembered" from session to session.

The following flow chart attempts to explain the algorithm. That's all for now. You may go walk the dog.