How to change grid row color in listpage form in Dynamics Ax 2012

I need to change the grid row’s color in ax 2012 depend on the record status. The usual solution for this is to override the formdatasource method displayoption(). However, the form is listpage type and DataSource method can not be overiden. Customization works only in the interaction class for listpages. I try to do this modification in to the interaction class but i couldn’t . After some search i find a solution. Firts export listpage form to xpo file and change form’s FormTemplate property to the none. Now you can override the displayoption() method with this code.


public void displayOption(Common _record, FormRowDisplayOption _options)
{
    #define.Green(0, 255, 0)
    #define.Orange(255, 128, 64)
    #define.LightGreen(64, 128, 128)
    #define.White(255, 255, 255)

    FRTImportTable importTable;
    ;

    importTable = _record.data();

    if (importTable.Status == FRTImportStatus::PreInvoice)
    {
        _options.backColor(WinAPI::RGB2int(#Green));
        _options.textColor(WinAPI::RGB2int(#White));
    }
    else if (importTable.Status == FRTImportStatus::OpenInvoice)
    {
        _options.backColor(WinAPI::RGB2int(#Orange));
    }
    else
    {
        _options.backColor(WinAPI::RGB2int(#LightGreen));
    }

    super(_record, _options);
}

Export new form to another xpo file. Open each xpo file and find displayoption() method from second xpo file. Copy and paste below code to the first xpo file between METHODS and ENDMETHODS branches.


SOURCE #displayOption
#public void displayOption(Common _record, FormRowDisplayOption _options)
#{
#    #define.DarkGray(80, 80, 80)
#    #define.LightGray(200, 200, 200)
#    #define.LightGray2(20, 20, 20)
#    #define.White(255, 255, 255)
#
#    FRTImportTable importTable;
#    ;
#
#    importTable = _record.data();
#
#    if (importTable.Status == FRTImportStatus::PreInvoice)
#    {
#        _options.backColor(WinAPI::RGB2int(#DarkGray));
#        _options.textColor(WinAPI::RGB2int(#White));
#    }
#    else if (importTable.Status == FRTImportStatus::OpenInvoice)
#    {
#        _options.backColor(WinAPI::RGB2int(#LightGray));
#    }
#    else
#    {
#        _options.backColor(WinAPI::RGB2int(#LightGray2));
#    }
#
#
#    super(_record, _options);
#}
ENDSOURCE

Save the first xpo and import to the ax.

Open your listpage form now you see the colors.

This is not a proper solution but i couldn’t find any other if you do let me know.

Until next time.

 
  • Trackback are closed
  • Comments (4)
    • Pir Mohammad
    • Ekim 16th, 2015 2:29pm

    HI,

    When you import the xpo file after modification, have check that list page property?

    it shows listpage but Interactionclass property will disappear. And you can override method like a normal form.

    Have you fine proper solution for this? if yes please share.

    Thanks in advance.

    • Hi,

      I don’t have a solution for this but i will try to figure out.

    • UMESH
    • Ekim 16th, 2015 2:32pm

    i have got Solution but you lost interaction class.
    same above .
    0- take xpo file of ur listpage. and create copy of that list page.
    1- fist change list page property to none.

    2 – create override method on data source.
    3 – take another xpo file of this list page.
    4 – look in that code copy from SOURCE to ENDSOURCE. paste in original list page xpo file.
    5- import original listpage that time ask override methos infotab select yes.
    6 – open ur original list page.

    then you got ur solution ‘Row Coloring’.

Comment are closed.