0

I have some problems with displayOptions method in AX 2012. I want to change form grid color where all inserted data is displayed, but my method also colors every other field that can be filled by client(Fields isnt in that grid). My method is writed in forms data source and it looks like this -

public void displayOption(Common _record, FormRowDisplayOption _options)
{
    KRHEvents events;

    events = _record;

    Switch(events.EventStatus)
    {

        Case 10:
    _options.backColor(65535); //Light Yellow

        Break;

        Case 30:
    _options.backColor(8421631); //Light Red

        Break;

        Case 20:
    _options.backColor(65408); //Light Green

    _options.textColor(12582912);
        Break;
    }

}

Form looks like this: Form

My goal is to remove colored fields in right side. That fillable fields shouldn't be colored. Maybe i have to override different method and in grid? I will appreciate any help!

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • Grid is used to display all inserted data, but with right side fields you can insert new fields. It means, grid and those fields has same data source. This method needs some changes or maybe i have to override some methods on grid? This current method is writed in data source method – Kristers Homičs Oct 21 '20 at 07:52

1 Answers1

0

You can specify which controls are affected by the back color.

_options.backColor(0x00FF80); // Light green
_options.affectedElementsByControl(OprId.id(), PatientId.id());

Also see this blog.

By the way never specify colors in decimal, convert to hex (BGR), 65535 = 0x00FFFF.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • The problem is - i use OperationID(and all other id's) in grind to display all inserted data, and also im using it in right side fields, where i can create new data. If i Specify to color OperationID, it will color it in form and right side fields. I think there is no escape then. – Kristers Homičs Oct 21 '20 at 11:32
  • Did you use affectedElementsByControl only specifying the grid controls? In that case it affects more controls than specified. – Jan B. Kjeldsen Oct 21 '20 at 12:17
  • @JanB.Kjeldsen - Why do you say "never specify colors in decimal, convert to hex"? Is there a specific reason? The method `WinAPI::RGB2int(...)` is used pretty extensively. – Alex Kwitny Oct 21 '20 at 16:29
  • @AlexKwitny That is also okay and equivalent. Decimal is not good. – Jan B. Kjeldsen Oct 21 '20 at 17:11
  • @JanB.Kjeldsen oh ok so you're saying hardcoded decimal then it sounds like? `RGB2int(...)` returns an `int` (the decimal sense I thought you were referring to). – Alex Kwitny Oct 21 '20 at 22:10