-->

AX 2012 - Define items of a combo box at design time

maqk® by Unknown | 11:27 AM

Combo box in AX 2012

Background

There are numerous ways to load values into a combo box in AX forms. The most common is to use base enums. One way is to use sysTableLookup to load master table data. Another way is to load another form at lookup event and interchange values using args. However sometimes its convenient to define custom items at design time. And such a thing is not very obvious in AX IDE. I recently discovered while answering an AX community post that HcmWorkerLookup form has an other way to do the same.

We all as ASP.Net developers know that we use to define the members of a ComboBox control. There is a similar way to do the same in AX as well. This is useful if your combo box has small no of items in it which are static, unchangeable values and are not suppose to update

Problem

When you have few static options to provide to user and for some reason, you want to show the user control as a combo box, you better define those few options at design time.

Solution(s)

I love AX due to the rapid development engine and reusable frameworks. AX provides the solution to the above problem definition by providing enough properties to define all the members / items under a combo box control. The ComboBoxControl has three properties which will be used.

You will have to focus on 3 properties on the combo box control. 

  1. Items It is the number of items (count) to appear on the combo at run time.
  2. Item  -  It is the currently selected item at design time, the following property works on the currently selected item
  3. Text -  It is the name or caption to appear for the currently selected item (number entered in Item property)

So how will you design it  ? E.g. you want three items to appear in your combo with values defined at design time and without involving any BaseEnum or table values or EDT relation. For three items, you will set the Items property of combo to 3. Then, to define the text values for each item, you will have to repeatedly update the Item property ( current item ) to 1,2, 3 and provide text value for each in the Text property.

Try it, its not cool may be, but knowing this IS COOL for sure ;)

Links

  • https://community.dynamics.com/ax/f/33/t/179483  

0 comments:

Post a Comment

top