Saturday, February 15, 2014

Highlighting record in Grid

It is possible to use colours in grids on Axapta forms. This can be a useful method to highlight particular rows, or grid cells within a row, based on the data in the record.

The method displayOption() method on a form datasource can be over-ridden to control the appearance of an single row in a grid. It is possible to set the background or foreground (text) colour. Since this is a form datasource method, the FormRowDisplayOption affects not only the grid, but also the other controls on this form connected to the datasource.

This method is executed once for each record before the record is displayed on a form.

The following example overrides the displayOption method to set display options, and to override the background color for the particular record.

public void displayOption(Common _record, FormRowDisplayOption _options)
{
     SalesLine    salesLineLocal;
     if (salesLineLocal.ItemGroup == 'ABC')
     {
         _options.backColor(WinApi::RGB2int(255,255,0)); // Yellow  
     }
}



No comments:

Post a Comment