Tuesday, 15 October 2013

Coloring for the rows in grid based on conditions




To display color to the selected row in display option

public void displayOption(Common _record, FormRowDisplayOption _options)
{
   RentalInquiryTmp rentalInquiry;
    rentalInquiry = _record;
    switch(rentalInquiry.Occupied)
    {
        case NetOccupied::Vacant:
            _options.backColor(65535);
           
            //_options.backColor(WinAPI::RGB2int(161,161,255));
            break;

        case NetOccupied::Occupied:
            _options.backColor(8421631);
          // _options.backColor(WinAPI::RGB2int(255,0,0));
            break;

        case NetOccupied::Inactive:
            _options.backColor(65408);
           //_options.backColor(WinAPI::RGB2int(0,0,255));
            break;
    }
    //super(_record, _options);
}

=====================================================================

Changing color of records/Individual fields based on flag in AX.


Hi,
The below code will provide different colors for different records in salestable form based on salesstatus enum..
public void displayOption(Common _record, FormRowDisplayOption _options)
{
SalesTable prodtablelocal;
prodtablelocal = _record;
Switch(prodtablelocal.SalesStatus)
{
Case SalesStatus::Delivered:
_options.backColor(65535); //Light Yellow
//_options.affectedElementsByControl(Salestable_SalesId.id());
Break;
Case SalesStatus::Invoiced:
_options.backColor(8421631); //Light Red
//_options.affectedElementsByControl(Salestable_SalesId.id());
Break;
Case SalesStatus::Backorder:
_options.backColor(65408); //Light Green
//_options.affectedElementsByControl(Salestable_SalesId.id());
_options.textColor(12582912);
Break;
}
}
Output:
IMG_08032013_145736
The below code will provide different colors for (only for selected fields) salesid field for a record in salestable form based on sales status enum.. this is done by uncommenting the _options.affectedElementsByControl(Salestable_SalesId.id()); lines.
In the same way, you can add different fields by setting autodecalaration to ‘Yes’ in design for respective fields in design > control names from the form.
public void displayOption(Common _record, FormRowDisplayOption _options)
{
SalesTable prodtablelocal;
prodtablelocal = _record;
Switch(prodtablelocal.SalesStatus)
{
Case SalesStatus::Delivered:
_options.backColor(65535); //Light Yellow
_options.affectedElementsByControl(Salestable_SalesId.id());
Break;
Case SalesStatus::Invoiced:
_options.backColor(8421631); //Light Red
_options.affectedElementsByControl(Salestable_SalesId.id());
Break;
Case SalesStatus::Backorder:
_options.backColor(65408); //Light Green
_options.affectedElementsByControl(Salestable_SalesId.id());
_options.textColor(12582912);
Break;
}
}
Output:
IMG_08032013_144737

No comments:

Post a Comment