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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to set 2 different color on 2 different column of Grid.

(0) ShareShare
ReportReport
Posted on by 476

HI Team,
I am trying to set 2 different colors on 2 columns of grid, but it is overlapping the first set color. with below code.


Please suggest how can it be possible.


  

public void displayOption(Common _record, FormRowDisplayOption _options)
{

    TestMPTempData    TestMPTempDataColor = _record;

    _options.affectedElementsByControl(TestMPTempData_POColor.id());

    if(TestMPTempDataColor.POColor == TestColors::Yellow)
    {
        _options.backColor(WinAPI::RGB2int(255, 255, 0));
        _options.textColor(WinAPI::RGB2int(255, 255, 0));
    }
    else if(TestMPTempDataColor.POColor == TestColors::Red)
    {
        _options.backColor(WinAPI::RGB2int(255, 0, 0));
        _options.textColor(WinAPI::RGB2int(255, 0, 0));
    }
    else
    {
        _options.backColor(WinAPI::RGB2int(0, 255, 0));
    }
   
    

  

    _options.affectedElementsByControl(TestMPTempData_SOColor.id());
    if(TestMPTempDataColor.SOColor == TestColors::Yellow)
    {


        _options.backColor(WinAPI::RGB2int(255, 255, 0));
        _options.textColor(WinAPI::RGB2int(255, 255, 0));
    }
    else if(TestMPTempDataColor.SOColor == TestColors::Red)
    {
       
        _options.backColor(WinAPI::RGB2int(255, 0, 0));
        _options.textColor(WinAPI::RGB2int(255, 0, 0));
    }
    else
    {
        
        _options.backColor(WinAPI::RGB2int(0, 255, 0));
    }
    super(_record, _options);
}

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi Vijay,

    I think this is the standard behavior - First call to the  _options.affectedElementsByControl will be overridden by the second call.

    If you want to set the color for the column you can try setting at the control level like below.

    ControlName.backGroundColor(WinAPI::RGB2int(255, 0, 0));

    Thanks,

    Girish S.

  • Vijay Yelmame VY Profile Picture
    476 on at

    Let me try and confirm.

  • Vijay Yelmame VY Profile Picture
    476 on at

    Hi Girish,

    I am expecting color to be change on the basis of its value , is this possible ?

    on which method i should write this so it will work for all Grid Record ?

  • GirishS Profile Picture
    27,827 Moderator on at

    I don't think you can set the background color for the control based on condition.

    Also its not possible to update the background color for all the grid records based on the condition.

    Thanks,

    Girish S.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans