Change grid row color in listpage form

Question Status

Suggested Answer
Muhammad Yasir asked a question on 9 Jul 2013 11:47 AM

Hi AX guys,

I need to change the  grid row's color if certain conditions are met. 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. the customization works only in the interaction class (AX 2012).  How can i do this in the interaction class.any idea or any sugestion.

Reply
Piyush Ojha responded on 5 Dec 2013 9:36 PM

Hi Yasir,

If you have find any solution regarding this query please post the solution.

I have also not find any solution regarding this query.

Reply
Mayur Chavhan responded on 20 Feb 2017 12:10 AM

Did you guys got any solution on this.

Do we have to do changes in interaction class ?

Any suggestions will be appreciated. ( Note: Grid color in listpageform, working in ax2012r3)

Reply
Suggested Answer
Kavitha Rajan responded on 20 Feb 2017 12:24 AM

Hi Yasir,

At First 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.

Reply
akshaykupra responded on 20 Feb 2017 12:26 AM

Hi Mayur,

try to explore tutorial form display option. from where you can get idea.

Reply
Mayur Chavhan responded on 22 Feb 2017 2:59 AM

Hi Kavitha,

I tried to follow your sugestion.

in my case there is custablelistpage form .

I exported the standard xpo of custablelistpage form.

Next step was to change the form template from "list page " to "none". But we cannot change it to none as it is disabled in standard case.  

How can we change its form template?

Reply
Mayur Chavhan responded on 22 Feb 2017 3:01 AM

Hi Akshaykupra,

Do you have link for tutorial which you are refering here ?

Reply
Suggested Answer
Kavitha Rajan responded on 22 Feb 2017 3:10 AM

Hi yasir,

For that reason, it may be better to change it's type to the specific table used in the datasource.

public void displayOption(CustTable _CustTable,FormRowDisplayOption _options)

{ int myColor=WinApi::RGB2int(50,255,50);

;

if(_CustTable.Currency=='EUR')

_options.backColor(myColor);

super(_CustTable, _options);

}

(or)

We can use an alternative to fulfill our requirement, in which we can set an indicator on the first column of the grid of the list page.This indicator can be the colorful small icon images. Which can be returned by display method of that particular table based on the conditions.

Reply
Suresh potlakayala responded on 22 Feb 2017 3:28 AM

..

Reply
Vilmos Kintera responded on 22 Feb 2017 3:53 AM

Suresh I am afraid your blog is unrelated, since we are talking about a ListPage here, which behaves differently from a regular form due to the requirements of Interaction classes. I would recommend to read up on it in the documentation, and stop linking irrelevant answers.

Reply
Mayur Chavhan responded on 23 Feb 2017 12:57 AM

do we have alternative to write displayoption method in listpageinteraction class

Reply
Suggested Answer
Kavitha Rajan responded on 23 Feb 2017 1:08 AM

Hi,

Please follow the instruction given in the below link,

http://www.fatihdemirci.net/index.php/2013/05/20/how-to-change-grid-row-color-in-listpage-form-in-dynamics-ax-2012/

Reply
Mayur Chavhan responded on 23 Feb 2017 3:25 AM

Hi kavita,

in this link provided by you, it is asked to change the form template. But as you can see in below screen shot that we cant change its form template as it is disabled.

Reply
Suggested Answer
Kavitha Rajan responded on 23 Feb 2017 3:38 AM

Hi Mayur,

     Events on the listpage (eg on data sources) are forwarded from the listpage to this class.

The displayoption method on the list page interaction class is triggered when the active method of data sources is executed.

Reply
Suggested Answer
Vilmos Kintera responded on 23 Feb 2017 4:17 AM

Mayur, you are missing the point of changing the value INSIDE the XPO yourself, not in the AOT, then reimporting it.

It is an unsupported modifications, and if you make any additional changes to the ListPage or the Query, you probably will lose the change from the form and have to apply it again.

Reply
Mayur Chavhan responded on 23 Feb 2017 4:32 AM

Hi Vilmos,

I am changing the formtemplate in xpo only by editing it.

When I am trying to import in ax, during compare it shows that our changes exist in xpo.  But when i try to import it in ax changes are not reflecting in system, and i am seeing only standard formtemplate. :(

Reply
Suggested Answer
Kavitha Rajan responded on 20 Feb 2017 12:24 AM

Hi Yasir,

At First 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.

Reply
Suggested Answer
Kavitha Rajan responded on 22 Feb 2017 3:10 AM

Hi yasir,

For that reason, it may be better to change it's type to the specific table used in the datasource.

public void displayOption(CustTable _CustTable,FormRowDisplayOption _options)

{ int myColor=WinApi::RGB2int(50,255,50);

;

if(_CustTable.Currency=='EUR')

_options.backColor(myColor);

super(_CustTable, _options);

}

(or)

We can use an alternative to fulfill our requirement, in which we can set an indicator on the first column of the grid of the list page.This indicator can be the colorful small icon images. Which can be returned by display method of that particular table based on the conditions.

Reply
Suggested Answer
Kavitha Rajan responded on 23 Feb 2017 1:08 AM

Hi,

Please follow the instruction given in the below link,

http://www.fatihdemirci.net/index.php/2013/05/20/how-to-change-grid-row-color-in-listpage-form-in-dynamics-ax-2012/

Reply
Suggested Answer
Kavitha Rajan responded on 23 Feb 2017 3:38 AM

Hi Mayur,

     Events on the listpage (eg on data sources) are forwarded from the listpage to this class.

The displayoption method on the list page interaction class is triggered when the active method of data sources is executed.

Reply
Suggested Answer
Vilmos Kintera responded on 23 Feb 2017 4:17 AM

Mayur, you are missing the point of changing the value INSIDE the XPO yourself, not in the AOT, then reimporting it.

It is an unsupported modifications, and if you make any additional changes to the ListPage or the Query, you probably will lose the change from the form and have to apply it again.

Reply
Suggested Answer
Kavitha Rajan responded on 23 Feb 2017 4:53 AM

Hi,

It is the Standard AX 2012 behaviour of the List Page forms it doesnt the override methods in the form.In the case of the normal forms - it allow to override the forms methods.So try by creating the form by having the formtempate - property as None(i.e. normal form)  and try to override the form methods and then change the form property FormTemplate to ListPage - it will throw  a message "the override methods will be deleted".

Reply