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)
Answered

Hiding a column in a grid using X++

(0) ShareShare
ReportReport
Posted on by 1,461

I added a new display method column to form: UnitOfMeasureLookup.

The standard columns are: Unit, Description and Translated Description where the last 2 columns are also display methods.

When the user is in edit mode in the sales order lines, and he/she clicks on the sales unit dropdown that opens the UnitOfMeasureLookup form, I must show the new display method and hide the Translated description display method.

When the user is in Product edit mode and click on the dropdown for purchase order units for example, the form must show the standard columns, thus the translated description display method column and not the new display method column.

I was able to hide/show the columns as needed. However AX shows the forth column even though it is blank. How do I tell in X++ for AX not to allocate space for the column that is hidden. In C# I would have run the bind() method of the grid again. There is no such thing in X++. We are using AX 2012 R3 cu12.

Salesorder Line:

Product details:

I'm overriding the Active-method of the datasource to hide/show the column depending from where the lookup form is called

*This post is locked for comments

I have the same question (0)
  • Muthusamy Profile Picture
    4 on at

    Hi R-AX,

    You have to pass the caller form as arguments to the lookup display method /look up form. Receive the arguments and then use some constraints from received arguments like menuitem name/formname/string parm value/  you can hide the column if it is lookup form. Otherwise, restrict the field in the lookup method. Also, you can restrict based on the form access rights.

    Thanks,

  • Retha Profile Picture
    1,461 on at

    I am hiding the column. I change the visible property. However it looks like the grid is drawn beforehand. Then the code is run to hide/show the column. However it hides/show the values in the cells of the column, not the column itself. So how do I hide the column itself. I need to redeaw the grid but how to do that in X++

  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    Hi R-AX,

    Could you please share your code ? Because hiding column usually should hide that column not value...

    Usually its something like MyTable_ds.object(fieldNum(MyTable, MyField)).visible(false);

    if control is bound to datasource or

    MyControl.visible(false) if it is not.

    Also it makes sense to do it once on init but not on active.

  • Retha Profile Picture
    1,461 on at

    Thank you Ievgen. I moved my code to the INIT method of the form and it is working now.

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sanhthosh.Kumar.K Profile Picture

Sanhthosh.Kumar.K 2

#2
Raed Salah Bzour Profile Picture

Raed Salah Bzour 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans