Skip to main content
Question

Color grid rows.


Forum|alt.badge.img

Hi All,

Need to know how to color grid rows based on grid value. 

Ex: if grid column value(x) equal to 1 then row color change to red else keeps default color.

Thanks

Bhagya

13 replies

Forum|alt.badge.img+6
  • Captain II
  • 578 replies
  • January 26, 2024

dcomerford
Captain II
Forum|alt.badge.img+15
  • Captain II
  • 648 replies
  • January 26, 2024

You will need to do a customisation in order to add it but fairly straight forward if you are comfortable with javascript. Here is a good article on it that should give you some pointer. If you search for javascript color Acumatica there is lots of info out there.

https://stackoverflow.com/questions/56582456/how-do-i-add-row-highlighting-to-a-customization-contained-within-a-base-acumati


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • January 29, 2024

Hi @bhagyat25 I have successfully completed the requirement around 2 years ago and provided the code in the below post. Hope this will help you.

 

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 51 replies
  • January 29, 2024
Naveen Boga wrote:

Hi @bhagyat25 I have successfully completed the requirement around 2 years ago and provided the code in the below post. Hope this will help you.

 

 

Hi @Naveen Boga ,

I applied everything as you given but page load event is not triggering. 

protected virtual void Initialize()
        {
            Page page = HttpContext.Current?.Handler as PXPage;
            if (page != null)
            {
                page.Load += Page_Load;
            }
        }

Can you tell me any other things to do?

Thanks

Bhagya


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • January 30, 2024

Hi @bhagyat25  After initialize code methid, write a Page_Load event for the colors like below and verify.

public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
    {

        public override void Initialize()
        {
            Page page = HttpContext.Current?.Handler as PXPage;
            if (page != null)
            {
                page.Load += Page_Load;
            }
        }

        private void Page_Load(object sender, EventArgs e)
        {
            Page page = (Page)sender;
            PXStyle rowStyle = new PXStyle();
            rowStyle.BackColor = System.Drawing.Color.FromArgb(232, 252, 255);
            page.Header.StyleSheet.CreateStyleRule(rowStyle, page, ".CssCurentRowStyle");

            PXStyle rowStyleEditing = new PXStyle();
            rowStyleEditing.BackColor = System.Drawing.Color.White;
            page.Header.StyleSheet.CreateStyleRule(rowStyleEditing, page, ".CssCurentRowStyleEditing");

            PXStyle cellStyleEditing = new PXStyle();
            cellStyleEditing.BackColor = System.Drawing.Color.FromArgb(255, 255, 220);
            page.Header.StyleSheet.CreateStyleRule(cellStyleEditing, page, ".CssCurentCellStyleEditing");

            PXStyle cellStyleLastCost = new PXStyle();
            cellStyleLastCost.BackColor = System.Drawing.Color.FromArgb(255, 217, 179);
            page.Header.StyleSheet.CreateStyleRule(cellStyleLastCost, page, ".CssCurentCellStyleLastCost");

            PXStyle cellStyleHeaderCurrent = new PXStyle();
            cellStyleHeaderCurrent.BackColor = System.Drawing.Color.FromArgb(232, 252, 255);
            page.Header.StyleSheet.CreateStyleRule(cellStyleHeaderCurrent, page, ".GridMain.Dash .GridRow.CssStyleHeaderCurrent");

            PXStyle cellStyleHeaderPreview = new PXStyle();
            cellStyleHeaderPreview.BackColor = System.Drawing.Color.FromArgb(255, 255, 220);
            page.Header.StyleSheet.CreateStyleRule(cellStyleHeaderPreview, page, ".GridMain.Dash .GridRow.CssStyleHeaderPreview"); 


            PX.Web.UI.PXGrid grdProfitBreakupByLine = (PX.Web.UI.PXGrid)ControlHelper.FindControl("grid", page);
            if (grdProfitBreakupByLine != null)
            {
                grdProfitBreakupByLine.RowDataBound += (object grdsender, PXGridRowEventArgs erdb) =>
                {
                    var data = erdb.Row.DataItem as PX.Objects.SO.SOLine;
                    if (data == null) { return; }

                    erdb.Row.Style.CssClass = data.CuryUnitPrice <= 0M ? "red20" : "black20";

                };
            } 
        } 
    } 

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 51 replies
  • January 30, 2024
Naveen Boga wrote:

Hi @bhagyat25  After initialize code methid, write a Page_Load event for the colors like below and verify.

public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
    {

        public override void Initialize()
        {
            Page page = HttpContext.Current?.Handler as PXPage;
            if (page != null)
            {
                page.Load += Page_Load;
            }
        }

        private void Page_Load(object sender, EventArgs e)
        {
            Page page = (Page)sender;
            PXStyle rowStyle = new PXStyle();
            rowStyle.BackColor = System.Drawing.Color.FromArgb(232, 252, 255);
            page.Header.StyleSheet.CreateStyleRule(rowStyle, page, ".CssCurentRowStyle");

            PXStyle rowStyleEditing = new PXStyle();
            rowStyleEditing.BackColor = System.Drawing.Color.White;
            page.Header.StyleSheet.CreateStyleRule(rowStyleEditing, page, ".CssCurentRowStyleEditing");

            PXStyle cellStyleEditing = new PXStyle();
            cellStyleEditing.BackColor = System.Drawing.Color.FromArgb(255, 255, 220);
            page.Header.StyleSheet.CreateStyleRule(cellStyleEditing, page, ".CssCurentCellStyleEditing");

            PXStyle cellStyleLastCost = new PXStyle();
            cellStyleLastCost.BackColor = System.Drawing.Color.FromArgb(255, 217, 179);
            page.Header.StyleSheet.CreateStyleRule(cellStyleLastCost, page, ".CssCurentCellStyleLastCost");

            PXStyle cellStyleHeaderCurrent = new PXStyle();
            cellStyleHeaderCurrent.BackColor = System.Drawing.Color.FromArgb(232, 252, 255);
            page.Header.StyleSheet.CreateStyleRule(cellStyleHeaderCurrent, page, ".GridMain.Dash .GridRow.CssStyleHeaderCurrent");

            PXStyle cellStyleHeaderPreview = new PXStyle();
            cellStyleHeaderPreview.BackColor = System.Drawing.Color.FromArgb(255, 255, 220);
            page.Header.StyleSheet.CreateStyleRule(cellStyleHeaderPreview, page, ".GridMain.Dash .GridRow.CssStyleHeaderPreview"); 


            PX.Web.UI.PXGrid grdProfitBreakupByLine = (PX.Web.UI.PXGrid)ControlHelper.FindControl("grid", page);
            if (grdProfitBreakupByLine != null)
            {
                grdProfitBreakupByLine.RowDataBound += (object grdsender, PXGridRowEventArgs erdb) =>
                {
                    var data = erdb.Row.DataItem as PX.Objects.SO.SOLine;
                    if (data == null) { return; }

                    erdb.Row.Style.CssClass = data.CuryUnitPrice <= 0M ? "red20" : "black20";

                };
            } 
        } 
    } 

 

Hi @Naveen Boga , Yes I did the same, But it is not working and to ensure that I put break points to both Page Load and Init methods, But none of them fired. Any clue?

Thanks

Bhagya

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • January 30, 2024

@bhagyat25  Have you chosen the right GRID ID from the .aspx page?

 

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 51 replies
  • January 31, 2024
Naveen Boga wrote:

@bhagyat25  Have you chosen the right GRID ID from the .aspx page?

 

 

Hi @Naveen Boga, Yes, It’s same as the grid id, my main issue is why these events not triggered once I put break points and attach the process in the VS. Any clue?

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • January 31, 2024

@bhagyat25 Can you please share the customization package here?

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 51 replies
  • January 31, 2024
Naveen Boga wrote:

@bhagyat25 Can you please share the customization package here?

 

Hi @Naveen Boga, Here is the package and screen id is RS403000. 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • January 31, 2024

@bhagyat25  You have added to the DLL but I cannot access it. Can you let me know how to populate the records in the grid?

 

 

 

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 51 replies
  • January 31, 2024
Naveen Boga wrote:

@bhagyat25  You have added to the DLL but I cannot access it. Can you let me know how to populate the records in the grid?

 

 

 

 

Hi @Naveen Boga , VS solution file and the table script. (BAccountID is from the BAccount Table)


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2787 replies
  • March 19, 2024

Hi @bhagyat25 were you able to find a solution? Thank you!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings