Skip to main content
Question

Dynamic row background coloring in the Batch Payment screen

  • September 22, 2025
  • 4 replies
  • 53 views

Forum|alt.badge.img+2

My ultimate goal is to change the background color of the Batch Payment screen grid based on two Boolean fields (UsrIsVendorVerified and UsrIsExcludeFromVerification) in CABatchDetailExt.

I attempted to achieve this using a JavaScript attribute, following the guidance from the post:


How do I add row highlighting to a customization contained within a Base Acumatica BLC?

 

Since that approach did not work as expected, I tried a simpler test coloring the grid rows without applying any conditions. However, even this did not work.

Script:

function HighligthLines ()
{
if(px_all && px_all["grid"] && px_all["grid"].rows)
{
let lines = px_all["grid"].rows.items;
for(let i=0;i<lines.length;i++)
{
let currentLine=lines[i];
currentLine.style.CssClass = "red20";
currentLine.repaint();
}
}
}


The Grid control doesn’t support a PXJavaScript attribute, so I added the PXJavaScript attribute to the form on the Batch Payment screen instead the Batch Payment grid is not contained inside a Tab attribute, so attaching the script directly to the grid wasn’t possible


For testing purposes, I also applied the same logic and method to the Journal Voucher screen in an attempt to color the Transactions grid, but that did not work either. The customization project is attached for reference.

4 replies

Forum|alt.badge.img+1
  • Semi-Pro III
  • September 22, 2025

@PDharmasena10 

you can achieve this in the pageLoad method. Please refer to the article below for more details.

https://community.acumatica.com/construction%2D120/customizing%2Dacumatica%2Ds%2Daspx%2Dcs%2D7764

 

Hope it helps!


Forum|alt.badge.img+2
  • Author
  • Semi-Pro I
  • September 22, 2025

Hi ​@svwk05 I tried this also. following is my code. Even that didn’t work.
 

        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) =>
{
CABatchDetail data = erdb.Row.DataItem as PX.Objects.CA.CABatchDetail;
CABatchDetailEftsureExt cABatchDetailEftsureExt = data.GetExtension<CABatchDetailEftsureExt>();
if (data == null) { return; }

erdb.Row.Style.CssClass = cABatchDetailEftsureExt.UsrIsVendorVerfied == true ? "green20" : "red20";
erdb.Row.Style.CssClass = cABatchDetailEftsureExt.UsrIsExcludeFromVerification == true ? "blue20" : "black20";


};
}
}

 


Forum|alt.badge.img+1
  • Semi-Pro III
  • September 22, 2025

@PDharmasena10 

Try the sample code below, where colors will be applied to the grid based on specific conditions.

This worked for me earlier when I implemented it

 

 private void Page_Load(object sender, EventArgs e)
{
Page page = (Page)sender;

PX.Web.UI.PXGrid grdProfitBreakupByLine = (PX.Web.UI.PXGrid)ControlHelper.FindControl("LicenseGrid", page);
if (grdProfitBreakupByLine != null)
{
grdProfitBreakupByLine.RowDataBound += (object grdsender, PXGridRowEventArgs erdb) =>
{
var data = erdb.Row.DataItem as "YourTableGrid";
if (data == null) { return; }
if (string.IsNullOrEmpty(data.Status)) /// Write your conitions
erdb.Row.Style.CssClass = ColorCodes.Blue20; // set colour
else if (data.Status == olorCodes.GracePeriod)
erdb.Row.Style.CssClass = ColorCodes.Orange20;
else if (data.Status == ColorCodes.Expired)
erdb.Row.Style.CssClass = ColorCodes.Red20;
else
erdb.Row.Style.CssClass = ColorCodes.Green20;
};
}
}

 


Forum|alt.badge.img+2
  • Author
  • Semi-Pro I
  • September 22, 2025

Hi ​@svwk05 , I tried bellow code inside my graph extension. that also not work then I include the Page_Load method in aspx.cs file also that also didn’t work. I tried this in 23R2 version

    public class CABatchEntry_Extension : PXGraphExtension<PX.Objects.CA.CABatchEntry>
{

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;

PX.Web.UI.PXGrid grdProfitBreakupByLine = (PX.Web.UI.PXGrid)ControlHelper.FindControl("grid", page);
if (grdProfitBreakupByLine != null)
{
grdProfitBreakupByLine.RowDataBound += (object grdsender, PXGridRowEventArgs erdb) =>
{
CABatchDetail data = erdb.Row.DataItem as PX.Objects.CA.CABatchDetail;
CABatchDetailEftsureExt cABatchDetailEftsureExt = data.GetExtension<CABatchDetailEftsureExt>();
if (data == null) { return; }

erdb.Row.Style.CssClass = cABatchDetailEftsureExt.UsrIsVendorVerfied == true ? "green20" : "red20";
// erdb.Row.Style.CssClass = cABatchDetailEftsureExt.UsrIsExcludeFromVerification == true ? "blue20" : "black20";
};
}
}