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 442

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);
}

  • GirishS Profile Picture
    27,823 Moderator on at
    RE: How to set 2 different color on 2 different column of Grid.

    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.

  • Vijay Yelmame VY Profile Picture
    442 on at
    RE: How to set 2 different color on 2 different column of Grid.

    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 ?

  • Vijay Yelmame VY Profile Picture
    442 on at
    RE: How to set 2 different color on 2 different column of Grid.

    Let me try and confirm.

  • Suggested answer
    GirishS Profile Picture
    27,823 Moderator on at
    RE: How to set 2 different color on 2 different column of Grid.

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,207 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans