Archive for Mayıs 20th, 2013

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.