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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Open a form on clicking a cell in a grid

(0) ShareShare
ReportReport
Posted on by

Is it possible to open a form that displays related data when I click on a cell in grid ?

For example, if I have a column called 'Expenses' in grid that displays expenses by an employee, then clicking on the cell under 'Expenses' column should open a new form or window that displays the detail breakup of the Expenses value. The grid contains other columns like Employee Name and Employee Location.

One of the problems in above scenario is that there is no cell-click event available for a grid column. There is a mouse down event, but even if I override it for a column, it fires for all other columns as well when I have not overridden mouse down event for these other columns.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Open a form on clicking a cell in a grid

    One of the problems in above scenario is that there is no cell-click event available for a grid column. There is a mouse down event, but even if I override it for a column, it fires for all other columns as well when I have not overridden mouse down event for these other columns.

  • Verified answer
    Annette Theissen Profile Picture
    1,653 on at
    RE: Open a form on clicking a cell in a grid

    Hi,

    yes you can: you can overwrite the mouseUp method on that field and invoke the form from the a menuItem.

    As an example, the following code opens the VendTable form initialized with an arbitrary vendor record. You would replace this with your menuItem and probably initialize with the current record of the grid.

    public int mouseUp(int _x, int _y, int _button, boolean _Ctrl, boolean _Shift)
    {
        int         ret;
    
        VendTable   vendTable;
        Args        args = new Args();
    
        ret = super(_x, _y, _button, _Ctrl, _Shift);
    
        select firstOnly vendTable;
        args.record(vendTable);
        new MenuFunction(MenuItemDisplayStr(VendTable),MenuItemType::Display).run(Args);
        
        return ret;
    }

    Hope this helps

    Kind regards,

    Annette

  • Suggested answer
    Ivan (Vanya) Kashperuk Profile Picture
    on at
    RE: Open a form on clicking a cell in a grid

    Well, you can override the MouseUp event on the above form control, and implement the logic for opening the dependent form in there.

    I would advice against that however.

    If nothing else, consider overriding the MouseDblClick method instead. This is prevent unintentional cases where the dependent details form is opened.

    But, that's also ugly, as it will conflict with the default grid action which navigates to the details of the record (like when you hit Enter on the grid).

    So I would simply go for a new button to open the relevant details.

  • Annette Theissen Profile Picture
    1,653 on at
    RE: Open a form on clicking a cell in a grid

    Did you add the mousedown method to the grid? If yes: Move it to the Real Control below the grid ...

  • Community Member Profile Picture
    on at
    RE: Open a form on clicking a cell in a grid

    Hi, The problem with mouse down/mouse up event is that it fires for every mouse down/up anywhere in the form area and not just for that column.  And this is creating the problem with mouse down/mouse up approach.

  • Community Member Profile Picture
    on at
    RE: Open a form on clicking a cell in a grid

    I added mouse down event to the column under the grid and not to the grid. But that is a problem as it will fire for mouse down anywhere in the grid or form.

  • Community Member Profile Picture
    on at
    RE: Open a form on clicking a cell in a grid

    Could I add the new button inside a grid column? I can add it to outside of grid  but I was looking for something like clicking a cell.

  • Annette Theissen Profile Picture
    1,653 on at
    RE: Open a form on clicking a cell in a grid

    [quote user="sun21170"]

    I added mouse down event to the column under the grid and not to the grid. But that is a problem as it will fire for mouse down anywhere in the grid or form.

    [/quote]

    That is really strange, I just rechecked my trial code and there, it only fires on mouse up in the one grid cell. Could you make sure that there is no other code leftover from previous trials?

  • Ivan (Vanya) Kashperuk Profile Picture
    on at
    RE: Open a form on clicking a cell in a grid

    No, you can't do that.

    The button outside of the grid is the pattern consistent with the other 3000+ forms in AX.

    Don't invent an unnecessary new pattern, use an existing one

  • Annette Theissen Profile Picture
    1,653 on at
    RE: Open a form on clicking a cell in a grid

    [quote user="sun21170"]

    Could I add the new button inside a grid column? I can add it to outside of grid  but I was looking for something like clicking a cell.

    [/quote]

    Well, not really a button control - the following solution is used in different places by standard AX;

    • add a Window control to the grid
    • implement the mouseUp as mentioned before.

    (In AX2012, as an example, look at form VendTable > Design > MainTab > TabPage Grid > Grid > Window PartyIndicator).

    But of course, this is effectively the same as implementing the mouseUp on the realControl. So, if you want to follow Ivans advice, you'd put the button "outside" of the grid ;-)

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
AlissonGodoy Profile Picture

AlissonGodoy 2

#2
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans