ENTERPRISE

Microsoft Dynamics AX 2009 : Building Lookups - Building a tree lookup

9/25/2012 1:48:53 AM
Form tree controls are a user-friendly way of displaying a hierarchy of related records like a company organizational structure, a bill of materials, projects, etc. Such a hierarchy can also be used in custom lookups allowing user to browse and select the required node in more convenient ways.

One of the previous recipes explained how to display the ledger budget model hierarchy in the Budget model form. In this recipe, we will reuse the previously created BudgetModelTree class to build a budget model tree lookup.

How to do it...

  1. 1. Create a new form in AOT:

    Property Value
    Name BudgetModelLookup

  1. 2. Set its design properties to:

    Property Value
    Frame Border
    WindowType Popup

  1. 3. Add a new Tree control to the form's design.

    Property Value
    Name ModelTree

  1. 4. Add the following line to the form's class declaration:

    BudgetModelTree budgetModelTree;
    
  2. 5. Override the form's init() with:

    public void init()
    
    {
    FormStringControl callingControl;
    ;
    callingControl = SysTableLookup::getCallerStringControl(
    this.args());
    super();
    budgetModelTree = BudgetModelTree::construct(
    ModelTree,
    callingControl.text());
    budgetModelTree.buildTree();
    }
    
  3. 6. Override mouseDblClick() and mouseUp() of the ModelTree control:

    public int mouseDblClick(
    int _x,
    int _y,
    int _button,
    boolean _ctrl,
    boolean _shift)
    
    tree lookuptree lookupbuilding, steps{
    int ret;
    ;
    ret = super(_x, _y, _button, _ctrl, _shift);
    element.closeSelect(
    this.getItem(this.getSelection()).text());
    return ret;
    }
    public int mouseUp(
    int _x,
    int _y,
    int _button,
    boolean _ctrl,
    boolean _shift)
    
    {;
    super(_x, _y, _button, _ctrl, _shift);
    return 1;
    }
    
    
    					  
  4. 7. The form should look like this in AOT:

  1. 8. Open the extended data type BudgetModelHeadId in AOT, and set its FormHelp property:

    Property Value
    FormHelp BudgetModelLookup

  1. 9. To see the results, open General ledger | Ledger budget, and expand Model lookup:

How it works...

First, we create a new form called BudgetModelLookup, which is an actual lookup. We set the Frame and WindowType design properties to Border and Popup respectively to change the layout of the form to be like lookup.

In the form class declaration, we define the BudgetModelTree class which we have already created in one of the previous recipes.

The code in the form's init() builds the tree. Here, we create a new budgetModelTree object by calling the constructor construct(), which accepts two arguments:

  1. 1. A control of type Tree, which represents the actual tree.

  2. 2. Budget model, which is going to be preselected initially. Normally, it's a value of the calling control, which can be detected by using getCallerStringControl() method of SysTableLookup application class..

The code in mouseDblClick() returns the user-selected value from the tree back to the calling control and closes the lookup.

mouseUp() has to be overridden to return 1 to make sure that the lookup does not close while the user expands or collapses tree nodes.

Other  
  •  Microsoft Dynamics AX 2009 : Building Lookups - Using a form for lookup building
  •  The HP Virtual Server Environment at a Glance : Overview of the HP Virtual Server Environment
  •  The HP Virtual Server Environment at a Glance : The Target Problem—Rampant System Over-Provisioning
  •  Oracle Coherence 3.5 : Clustered cache topologies (part 3) - Near cache
  •  Oracle Coherence 3.5 : Clustered cache topologies (part 2) - Partitioned Cache service
  •  Oracle Coherence 3.5 : Clustered cache topologies (part 1) - Replicated Cache service
  •  Oracle Coherence 3.5 : Planning Your Caches - Anatomy of a clustered cache
  •  Memory Management : Clean Up Managed Resources Using the Dispose Pattern
  •  Memory Management : Get the OS View of Your Application's Memory, Clean Up Unmanaged Resources Using Finalization
  •  Active Directory Domain Services 2008 : Create a WMI Filter, Import a WMI Filter, Export a WMI Filter
  •  
    Top 10
    Review : Sigma 24mm f/1.4 DG HSM Art
    Review : Canon EF11-24mm f/4L USM
    Review : Creative Sound Blaster Roar 2
    Review : Philips Fidelio M2L
    Review : Alienware 17 - Dell's Alienware laptops
    Review Smartwatch : Wellograph
    Review : Xiaomi Redmi 2
    Extending LINQ to Objects : Writing a Single Element Operator (part 2) - Building the RandomElement Operator
    Extending LINQ to Objects : Writing a Single Element Operator (part 1) - Building Our Own Last Operator
    3 Tips for Maintaining Your Cell Phone Battery (part 2) - Discharge Smart, Use Smart
    REVIEW
    - First look: Apple Watch

    - 3 Tips for Maintaining Your Cell Phone Battery (part 1)

    - 3 Tips for Maintaining Your Cell Phone Battery (part 2)
    VIDEO TUTORIAL
    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
    Popular Tags
    Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8