Changing color of records/Individual fields based on flag in AX
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;
}
}
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;
}
}
How to colorize Rows In Grid With Different colors using X++ in AX 2009?
You need in sometimes to colorize specific rows with different color to do anything in your business rules to do this :
1- Go to the data source of your form
2- Choose that data source is used by the grid that you want to color it
3- write click on the override method and select displayOption method and put the following code inside
public void displayOption(Common _record, FormRowDisplayOption _options)
{
if (_record.(fieldnum(MBST_PAYMENTS_HDR,POST_FLAG))=="YES")
{
_options.backColor(WinAPI::RGB2int(161,161,255));
}
super(_record, _options);
}
Changing Form color based on the current Company
Basically you override the SysSetupFormRun.run() method. Below is some sample code:
public void run()
{
;
super();
// Set the color scheme of this instance of te SysFormRUn to RGB
this.design().colorScheme(FormColorScheme::RGB);
// Switch and based on the current company change colors, or not for default
switch (curext())
{
case 'DEM':
this.design().backgroundColor(WinAPI::navisionColorRed());
break;
case 'dat':
this.design().backgroundColor(WinAPI::navisionColorBeige());
break;
default:
break;
}
}
Now when you switch between the two companies and launch a form, you will see visually, that you are in a different company. Granted the WinAPI::navisionColorBeige(), ..Blue(), ..Red() are not that great looking, but still you get the idea. And if
you know RGB colors, then you can supply really any valid RGB color you like!
Anyway this is a neat little trick that is ran each time a new instance of a given form (other that the main menu) is ran.
http://daxguy.blogspot.in/2007/04/coloring-grids-in-dax.html
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;
}
}
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;
}
}
How to colorize Rows In Grid With Different colors using X++ in AX 2009?
You need in sometimes to colorize specific rows with different color to do anything in your business rules to do this :
1- Go to the data source of your form
2- Choose that data source is used by the grid that you want to color it
3- write click on the override method and select displayOption method and put the following code inside
public void displayOption(Common _record, FormRowDisplayOption _options)
{
if (_record.(fieldnum(MBST_PAYMENTS_HDR,POST_FLAG))=="YES")
{
_options.backColor(WinAPI::RGB2int(161,161,255));
}
super(_record, _options);
}
Changing Form color based on the current Company
Basically you override the SysSetupFormRun.run() method. Below is some sample code:
public void run()
{
;
super();
// Set the color scheme of this instance of te SysFormRUn to RGB
this.design().colorScheme(FormColorScheme::RGB);
// Switch and based on the current company change colors, or not for default
switch (curext())
{
case 'DEM':
this.design().backgroundColor(WinAPI::navisionColorRed());
break;
case 'dat':
this.design().backgroundColor(WinAPI::navisionColorBeige());
break;
default:
break;
}
}
Now when you switch between the two companies and launch a form, you will see visually, that you are in a different company. Granted the WinAPI::navisionColorBeige(), ..Blue(), ..Red() are not that great looking, but still you get the idea. And if
you know RGB colors, then you can supply really any valid RGB color you like!
Anyway this is a neat little trick that is ran each time a new instance of a given form (other that the main menu) is ran.
http://daxguy.blogspot.in/2007/04/coloring-grids-in-dax.html
How is it possible in AX 2012 listpages e.g., custtablelistpage.
ReplyDeleteIs it possible to colorize field added to grid by user?
ReplyDeletehere is the blog where we can achieve this using method override/ Event handler on existing form.
ReplyDeletehttp://d365technext.blogspot.com/2018/08/gridlist-row-color-change-using-method.html