Grid Line Color Set Conditionally

Last modified: 

12/12/24




Add colors to grid lines conditionally.

Want to add grid lines based on a condition to call attention to them? This is something we used to be able to do in AX 2012 but this feature was quietly removed when we moved to AX 7 / Finance and Operations. However, it was very quietly added back in as an available feature somewhere around 10.0.36 ( or there abouts ). Below is an example screenshot and code sample for how to do this. In the example, I am changing the grid line color for all cells that contain data based on the customer’s credit limit. We have 3 different “credit limit color” buckets for the grid to use. 

And the code for this is pretty simple. Extend displayOption then set a color based on a range. The syntax below is a method of defining the “buckets” using tiers with a switch(true) with my conditions in reverse order of how you would typically present them. You can use this to define colors to call out specific items that require attention when displaying items in a grid.

[ExtensionOf(formDataSourceStr(CustTable, CustTable))]
internal final class aaxCustTable_CustTableDS_Extension
{
    public void displayOption(Common _record, FormRowDisplayOption _options)
    {
        CustTable CustTable;

        if(_record &&
           _record.TableId == tableNum(CustTable))
        {
            CustTable = _record as CustTable;

            switch(true)
            {
                case(custTable.CreditMax > 5000000):
                    _options.backColor(WinAPI::RGB2int(0, 255, 69));  // Green
                    break;

                case(custTable.CreditMax > 500000):
                    _options.backColor(WinAPI::RGB2int(125, 134, 255));   // light blue
                    break;

                case(custTable.CreditMax > 50000):
                    _options.backColor(WinAPI::RGB2int(143, 143, 143));   //gray
                    break;

            }

        }

        next displayOption(_record, _options);
    }

}

Original Post https://www.atomicax.com/article/grid-line-color-set-conditionally

0 Votes: 0 Upvotes, 0 Downvotes (0 Points)

Leave a reply

Join Us
  • X Network2.1K
  • LinkedIn3.8k
  • Bluesky0.5K
Support The Site
Events
March 2025
MTWTFSS
      1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31       
« Feb   Apr »
Follow
Sign In/Sign Up Sidebar Search
Popular Now
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...