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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

dynamically add fields to a From Grid Control

(0) ShareShare
ReportReport
Posted on by

a customer wants to a customized "LedgerTransAccount" Form

They want to have a checkbox to activate the "Transaction Origin". If the checkbox is marked true the grind on the form should show fields for "Module" and LedgerAccount of the Transaction Origin.

So it must be something dynamic because you do not know how many fields you have to add

How can I realize s.th. like this?

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,668 Super User 2026 Season 1 on at

    so, why you don't think to add temp table??

    using temp table you can show as many values in grid, as you want, at run time.

  • Community Member Profile Picture
    on at

    well I am not sure if I missunderstood or you did.

    I want to have the fields in addition on the same row like the "MainInfo". Maybe 4 fields (2 with Module, 2 with related LedgerAccount), maybe 6, 8 or 10 what is related in the Transaction origin

    A temp table would not help to get the data in one single row, would it?

  • Suggested answer
    Iulian Cordobin Profile Picture
    8,201 on at

    You want to implement like this:

    a) add the two column in the grid and make them Visible = false;

    b) on the clicked event of the checkbox column perform a Visible = true, or = false, depending on the state of the checkbox.

  • Community Member Profile Picture
    on at

    no Option because I do not know in advance how many columns it would be

  • Sohaib Cheema Profile Picture
    49,668 Super User 2026 Season 1 on at

    I am not sure, what exactly you are looking for.

    definitely its possible to add new fields dynamically; Also using temp table(if that is feasible for you)

    if you can present your case with some image etc. may be someone can suggest you a good solution

  • Community Member Profile Picture
    on at

    ledger.JPG

    It should look like this

  • Sohaib Cheema Profile Picture
    49,668 Super User 2026 Season 1 on at

    its not possible to display such data with a single row.

    I know these screens very well. Itself, Microsoft is using tempTable with class OrignalDocuments.

    if I will be in your shoes, I will use temp table and I will display a grid for which data will change with each active record.

    I will not comment on it further because my choice will still be temp table, in such case, which is not acceptable for you.

  • Community Member Profile Picture
    on at

    oh you got me wrong tmpTable is fine. I just thought that it will not resolve my problem...from the point of view to add the additional data in a separate grid for sure it will work

  • Verified answer
    Brandon Wiese Profile Picture
    17,790 on at

    I've done something like what I think you're suggesting.  It's never pretty.

    Basically, I created a temp table with a series of numbered fields, i.e. Item1, Text1, Item2, Text2, Item3, Text3, etc.  The problem up front with this approach is that you just have to decide on a maximum number of fields to support and live with it.  Don't even think about adding fields to a temp table during runtime.

    Adding the temp table as a data source to your form is easy.  Deciding how many of those fields to hide or show is also pretty easy.  You'll probably add them all as fields in the grid up front, and just change .visible() as needed on each field in response to your "show" checkbox.

    Populating the data is a whole other issue.  Pivoting rows into columns is just coding.

    It's certainly possible to actually add fields to a grid at runtime, and they can be bound to fields or data methods.  I don't see the advantage of adding them at runtime when it's just easier to show/hide them dynamically.  I'm also not sure how you could add a variable number of controls to the grid bound to a display method, since you can't specify parameters for the data method.  You could do it with many different data methods (display methods), but it's messy.

  • Community Member Profile Picture
    on at

    Hi Brandon

    Sounds pretty good to me but how can I "connect" the entries in the tmpTable to the record in the grid?

    Actually I fill the tmpTable with the data but I do not know how I can link the tmpdata with grid line 1, line 2, etc.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans