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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Loop through grid fields in Ax 2012 in RUNTIME

(0) ShareShare
ReportReport
Posted on by 15

Hello,

I need logic to loop through columns(fields) in grid in runtime.

Something similar to this AX 2012: Loop through all the fields of a table in X++ - Dynamics 365 Finance Community  but in runtime.

For example if grid data source has 5 columns and 3 are removed in UI, i want to loop just through these 2 that are left in the grid. So my question is how to get grid fields in runtime( not from datasource table) ?

Thank you.

I have the same question (0)
  • Viktors Profile Picture
    15 on at

    This looks totally different from that what i am looking for.

    I need to get grid in the runtime to do additional operations in backend.

  • André Arnaud de Calavon Profile Picture
    301,130 Super User 2025 Season 2 on at

    Hi Viktors,

    Is your question related to Dynamics AX 2012?

  • Viktors Profile Picture
    15 on at

    Hi,

    Yes, I am asking about Dynamics AX 2012 grid, i want to loop through all fields in the grid.

    So if I loop through data source of the grid I can achieve it, but if user personalize the grid(add or remove columns on UI) I want to loop through these columns, so that's why I need to catch grid in runtime.

    kind regards

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,130 Super User 2025 Season 2 on at

    Moved to the Dynamics AX forum.

    Hi Viktors,

    The Export to Excel from the Grid is actually doing the same job (exporting the columns visible on the grid). You can review how Microsoft did implement it for this feature.

  • Viktors Profile Picture
    15 on at

    Yes, I know and I thought that SysExcel classes do it, but I investigated them and they don't do anything related to that what I need.

    So if you have any documentation or reference about Export to Excel function please share with me, thank you.

    kind regards

  • ergun sahin Profile Picture
    8,826 Moderator on at

    You can use isVisible

    Set all fields's autoDecleration to Yes and check with control.isVisible

    As a alternative I wrote a code with treeNode but it seems treeNode can't get usage Data from user. I didn't want spent to much time, probably I didn't catch some point. Here the code, maybe it can be helpfull

    static void dmr_ES_GetFormFieldsInfoWithTreeNode(Args _args)
    {
        TreeNode        treeNode = TreeNode::findNode(@'\Forms\DmrESTestFormVisible\Designs\Design\[Grid:Grid]');
        treeNode        treeNodeChild;
        TreeNodeType    treeNodeType;// = treeNode.treeNodeType();
        FormControl     FormControl;
        
        FormTreeControl FormTreeControl;
        
        void nodeInfo(treeNode _treeNode)
        {
            if(treeNodeChild.treeNodeName() != "Methods")
            {
                treeNodeType = _treeNode.treeNodeType();
               
                //info(strFmt("Id: %1", treeNodeType.id()));
                info(strFmt("Name: %1", _treeNode.treeNodeName()));
                info(strFmt("Name: %1", _treeNode.AOTname()));
                info(strFmt("AllProperties: %1", _treeNode.AOTgetProperties()));
                
                info(strFmt("Visible: %1", _treeNode.AOTgetProperty("Visible")));
                info(strFmt("isVisible: %1", _treeNode.AOTgetProperty("Visible")));
            }    
        }
        if(treeNode)
        {            
            if(treeNode.AOTchildNodeCount())
            {
                treeNodeChild = treeNode.AOTfirstChild();
                
                nodeInfo(treeNodeChild);
                while(treeNodeChild.AOTnextSibling())
                {             
                    treeNodeChild = treeNodeChild.AOTnextSibling();   
                    nodeInfo(treeNodeChild);
                }
            }
        }
    }

  • ergun sahin Profile Picture
    8,826 Moderator on at

    isVisible Example

    pastedimage1661804439400v1.png

    pastedimage1661804526044v2.png

  • Community member Profile Picture
    4 on at
    I was also looking for this information.
  • Community member Profile Picture
    4 on at
    I was also looking for this information. Luckily I saw your post. Thanks a lot. slope 3

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans