Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Grid Cell Color

(0) ShareShare
ReportReport
Posted on by

Hi everyone,

I am using dynamics ax 2012 and new to development. I want to colorize the grid cells based on its value.  So same row may contains cells with different color. For this, i am overriding displayoptions() of Data source.  But i realized that  only the last set color is affecting the entire cells in a row. How can i achieve this.

As an another example i am using the following code to colorize different columns

public void displayOption(Common _record, FormRowDisplayOption _options)

{

   _options.backColor(WinApi::RGB2int(255,0,0));

   _options.affectedElementsByControl(FIELD_1.id());

    _options.backColor(WinApi::RGB2int(0,0,255));

    _options.affectedElementsByControl(FIELD_2.id());

Here i am expecting red color for FIELD_1 and blue color for FIELD_2.  But i am getting both the columns with blue color.

please suggest the code for achieving the desired result

*This post is locked for comments

  • Verified answer
    PA-22040759-0 Profile Picture
    6,194 on at
    RE: Grid Cell Color

    Please have a look at the Tutorial_Form_Table form, which you can find in the AOT.

    And here is a link to the MSDN documentation: msdn.microsoft.com/.../formtablecontrol.aspx

  • Community Member Profile Picture
    on at
    RE: Grid Cell Color

    Thanks Andre, palle..

    It would be helpful if you could provide me something useful tutorial about FormTableControl that suits my requirement.

  • André Arnaud de Calavon Profile Picture
    294,770 Super User 2025 Season 1 on at
    RE: Grid Cell Color

    We had once a challenge where we could not even use this FormTableControl. We ended up in placing controls dynamically on the form and use a vertical scrollbar to show records that did not fit on the form.

    Was years back with AX3.0.

  • PA-22040759-0 Profile Picture
    6,194 on at
    RE: Grid Cell Color

    I must admit that with fifteen years of experience with AX, I only this one time found it relevant to use the FormTableControl for anything :-)

  • André Arnaud de Calavon Profile Picture
    294,770 Super User 2025 Season 1 on at
    RE: Grid Cell Color

    Hi No man, Palle,

    I was about writing about the FormTable control. This indeed can have a color per cell, but you have to manually fill the cells. Be careful with much records in this control.

  • Suggested answer
    PA-22040759-0 Profile Picture
    6,194 on at
    RE: Grid Cell Color

    I have had a similar requirement from a customer, and it won't work with the grid control.

    I ended up solving this using the FormTableControl. In the AOT there is a tutorial form for this control.

    But it will give you a lot more work to do to present the data.

  • Community Member Profile Picture
    on at
    RE: Grid Cell Color

    Hi  Andrea,

    Per record only one back color means I cannot specify cell wise coloring based on cell value. My grid has  many columns having cell values like  L, S,P, A etc.  I  need to mark each cell value with different color.  In that case one row may affected by different colours.  ( example in row 1  Col A value - L, Col B value - P ...).  So is there any solution in such a situation.

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    294,770 Super User 2025 Season 1 on at
    RE: Grid Cell Color

    Hi No Man,

    Per record you can have only one back color. It is not per control.

    The affectedElementsByControl is only for specifying which contols needs to have the background color if you don't want to have all controls marked with the background..

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans