web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

how to get the FormTreeItem's first parent of current selected item from Tree control?

(0) ShareShare
ReportReport
Posted on by 932

I want to know how to get the current selected item from tree,

also get its parent ?

1050.tree.png

I means that : whenI click on this item  I get  this item ans its parent.

*This post is locked for comments

I have the same question (0)
  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Basma,

    Refer this: community.dynamics.com/.../149593

  • BASMA Profile Picture
    932 on at

    hi @Blue Wang ,

    I need how to get the parent of child in tree like in the image not from the AOT

  • BASMA Profile Picture
    932 on at

    I Have clicked button in form:
    when I clicked on it I want to get the parent Node from tree control:
    this is the code in method clicked:

    public void clicked()
    {
        TreeItemIdx                 treeItemIdx, idx,parentIdx,parentNodeIdx;
        FormTreeItem                formTreeItem,formRoot;
        boolean                     modify;
        TreeNode                    treeNode;
        EUKSecurityMenus            securityMenus,securityMenusParent;
        str                        pathRoot;
    
    
        treeItemIdx = NavigationTree.getFirstSelected();
        formTreeItem = NavigationTree.getItem(idx);
        FormRoot=element.getFormTreeItem(treeItemIdx);

    }

    for example:
    formTreeItem=\ Fixed Assets \ States \ External \ Capital Statement  => I want to get formRoot=\ Fixed Assets \

    I created method getFormTreeItem :

    public  FormTreeItem  getFormTreeItem(TreeItemIdx _treeItemIdx)
    {
      
         FormTreeItem      formTree, formRootNode;
       
        formRootNode=NavigationTree.getItem(_treeItemIdx);
        if(NavigationTree.getParent(_treeItemIdx)!=0)
        {
           itemRootIdx=NavigationTree.getParent(_treeItemIdx);
            formTree=element.getFormTreeItem(itemRootIdx);
        }
    
      return formRootNode
    }


    But I didn't get the exact fromTreeItem.

     
  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Basma,

    Please refer this: https://community.dynamics.com/365/financeandoperations/b/mfp/archive/2002/06/01/how-to-use-a-formtreecontrol/

    FormTreeItem    selectedItem;
    
    selectedItem = tree.getItem(tree.getSelection());
    
    info(selectedItem.text());


  • BASMA Profile Picture
    932 on at

    Hi Blue wang,

    its not what I want.

    I want to get the formTreeItem Of parent Like I explained in last comment

  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Basma,

    Your method getFormTreeItem()  has a return value, but it's not the node you want.  right?

  • BASMA Profile Picture
    932 on at

    I want that this method returns the FormTreeItem from the TreeItemIdx                

  • BASMA Profile Picture
    932 on at

    I just found a solution :)

    I changed the method getFormTreeItem() :

    public  FormTreeItem  getFormTreeItem(TreeItemIdx _treeItemIdx)
    {
    
    
        FormTreeItem  formTree;
        formTree=NavigationTree.getItem(_treeItemIdx);
        if(NavigationTree.getParent(_treeItemIdx)!=0)
        {
    
            formTree=this.getFormTreeItem(NavigationTree.getParent(_treeItemIdx));
    
        }
    
      return   formTree;
    
    
    }


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
GL-01081504-0 Profile Picture

GL-01081504-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans