Wednesday, 19 February 2014

Coloring for the rows in grid based on conditions

Coloring for the rows in grid based on conditions


To display color to the selected row in display option(The code must be placed in the displayOption() method of the datasource.)

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);

}






Coloring Grids in DAX

tutHeres some tips on how to color Grid Cells / rows in DAX. Ive used the prodTable form as an example.The code must be placed in the displayOption() method of the datasource.
Case 1:
Color specific rows
Code :

public void displayOption(Common _record, FormRowDisplayOption _options) 
{ 
prodtable prodtablelocal; 
prodtablelocal = _record; 
Switch(prodtablelocal.ProdStatus) 
{ 
Case ProdStatus::Created: 
_options.backColor(6029311); //Light Yellow 
_options.textColor(12582912); //Blue 
Break;
Case ProdStatus::Completed: 
_options.backColor(16761281); //Light Blue
_options.textColor(12582912); //Blue
Break;
}
} 

Display:


Case 2: Color specific cells 
Code :
 
public void displayOption(Common _record, FormRowDisplayOption _options) 
{
prodtable prodtablelocal; 
prodtablelocal = _record;
Switch(prodtablelocal.ProdStatus)
{
Case ProdStatus::Created: 
_options.backColor(65535); //Light Yellow
_options.affectedElementsByControl(ProdTable_ProdId.id());
Break; 
Case ProdStatus::Released:
_options.backColor(8421631); //Light Red 
_options.affectedElementsByControl(ProdTable_ProdId.id());
Break;
Case ProdStatus::Completed:
_options.backColor(65408); //Light Green
_options.affectedElementsByControl(ProdTable_ProdId.id());
Break; 
}
}

Display:



Now to get the color codes u want , look at the formtutorial_Form_DisplayOptions.
Tweak it a bit by adding this line in
\Forms\tutorial_Form_DisplayOptions\Designs\Design\[ButtonGroup:ButtonGroup]\Button:SetColor\Methods\clicked()

if (conlen(c)) 
{ backColor = WinAPI::RGB2int( conpeek(c,1), conpeek(c,2), conpeek(c,3) ); 
Info(Strfmt("%1",backColor)); // Add this line 
// Clear the display options for the once which allready has been set. 
for (common = custTable_ds.getFirst(); common; common = custTable_ds.getNext()) 
{



No comments:

Post a Comment