How to change the colour of grid cells in Dynamics AX

This question is not answered

Hi,

I have a scenario in which i want to change the colour of the grid cell whenever i clicked/select that particular cell.The problem is that displayOption method of the datasource is not called when i select that cell.I do not know how to call the DisplayOption method manually.

DisplayOption method takes two arguments.

1. Record

2 FormRowDisplayOption (object)

The problem is that i dont know how to initialize and pass the second argument that is FormRowDisplayOption to the displayOption method.and whether tsome properties needs to be set for the object before passing to the method.

Please give me any solution if any one knw it.

Thnaks.
Muhammad Yasir

All Replies
  • It seems impossible to create a FormRowDisplayOption in custom code. But maybe you could get the instance when displayOption() is called by AX kernel for the given record, save it to a variable and use it for your purposes.

    Martin "Goshoom" Dráb | Freelancer | Goshoom.NET Dev Blog

  • Thanks Martin for your prompt reply, as you have said that i can get the instance when displayOption() is called by AX kernel for the given record, the problem is when i click a particular cell of grid displayOption() is not called automatically, so forcefully i have to call the displayOption() method manually, but i don't know how to correctly pass the object of FormRowDisplayOption as argument to the displayOption() method.

    i have tried the following code in the enter() method, but i got an error,

    FormRowDisplayOption  obj = new FormRowDisplayOption();

    obj.backColor(WinAPI::RGB2int(161,161,255));

    FormDatasource.displayOption(Record, obj);

    Here is the error:

    Error executing code: Object object does not have method 'backColor'.

    Is there any solution.

    Thanks,

  • I understand the problem and I wrote that I think that you can't construct FormRowDisplayOption by yourself. But you can store the FormRowDisplayOption instance created by AX kernel and try to use the same instance in subsequent calls.

    Martin "Goshoom" Dráb | Freelancer | Goshoom.NET Dev Blog

  • I have tried what you have suggested, i successfully store the FormRowDisplayOption instance created by AX kernel,but in doing so another problem arises that is the record that i pass to the displayOption() method will not be highlighted in the grid,It will highlight only that record in the grid that is first used ie. when the form loads and at that moment a record is in memory so it will highlight that record.

    hope you have understand the scenario

    Any solution for this as well, i appreciate your for the prompt response,

    regards,

    Yasir