Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Hiding a column in a grid using X++

Posted on by 1,423

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

  • Retha Profile Picture
    Retha 1,423 on at
    RE: Hiding a column in a grid using X++

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

  • Verified answer
    Mea_ Profile Picture
    Mea_ 60,274 on at
    RE: Hiding a column in a grid using X++

    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
    Retha 1,423 on at
    RE: Hiding a column in a grid using X++

    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++

  • Muthusamy Profile Picture
    Muthusamy 4 on at
    RE: Hiding a column in a grid using X++

    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,

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,914 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,549 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans