Solved

customizing Acumatica’s aspx.cs


Userlevel 2
Badge

Is there any way to customize Acumatica’s pages .cs code inside the customization projects or VS? For starter I would like to get rid eye hurting red color of Approvals screen.

icon

Best answer by Naveen B 4 January 2022, 04:46

View original

23 replies

Userlevel 6
Badge +4

Hi @aaghaei Yes, it is possible to customize the .cs files. Please find the below screenshot from development guide.

 

Userlevel 6
Badge +4

Hi @aaghaei Please find the below customization guide for more details. Hope this is helpful.

https://www.acumatica.com/media/2020/09/AcumaticaERP_CustomizationGuide.pdf

Userlevel 2
Badge

Thanks @ChandrasekharM for the comment. I guess I wasn’t clear enough. I know we can customize DACs and Graphs and Pages and I have done quite a lots these changes. There is an special .cs file for each page named ScreenID.aspx.cs and I want to customize them. Any thoughts?

Userlevel 5
Badge +1

Hi @aaghaei 

If you are creating a new screen, you can write the logic on the aspx.cs file. But the existing screen, I don't think we can customize the aspx.cs.
 

 

 

To add color for a grid, please refer to the below links

Acumatica Visual Cues - How to colorize the grid in 2019 R1? - InfoSourcing Inc, Acumatica Partner - Washington DC, NY, FL (info-sourcing.com)

Using Colors in Acumatica - Acumatica Developers Blog .

 

Userlevel 7
Badge +11

@aaghaei  You wanted to customise existing screen .aspx.cs OR on custom screen,which you developed? 

Userlevel 2
Badge

Thanks @jinin for the comments

Userlevel 2
Badge

Hi @Naveen B, When we create new screens considering we have both ASPX and ASPX.cs file under full control we can override the logics. I have done on one on my screens and had no problem with highlighting the rows as per my defined conditions. What I’m asking is about customizing Acumatica’s existing out-of-box pages .aspx.cs file. Can you please shed some light as always you do? Thank you.

Userlevel 7
Badge +11

@aaghaei  I have never done this, I’m not seeing any option to add this .aspx.cs code to customisation package.

Could you please let me know the business requirement?

Userlevel 2
Badge

Thanks @Naveen B,

What I would like to do is showing different font colors based on the approval status of Approvals grid. I would like to show approved records in Green and Rejected ones in Red. In addition we have added custom status “Routed” that would like to show in Black or Blue. It helps easily see what are the different statuses by colore coding.

 

In addition I would like to take red color from Approvals screen which is shown for ALL records as aproval map consideres them as escalated. 

Userlevel 7
Badge +11

Hi @aaghaei  Thanks for sharing the details.

I dig into deep and done some R&D and worked on it. I can able to provide the colors to the Grid lines for the existing screen i.e. Sales Order screen.

In this case, we no need to override the .aspx.cs file, we can still work on the SOOrderEntry Extended Graph to provide the colors based on the conditions, which I worked below.

I have attached code and screenshots for your reference.

 

 

Sample Source Code

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

};
}
}
}

 

Hope this helps for your requirement!!

 

Userlevel 6
Badge +4

Hi @Naveen B Very nice!!

Userlevel 7
Badge +11

Thanks a lot @ChandrasekharM  :) 

Userlevel 2
Badge

Thanks @Naveen B. Absolutly Awsome. 

Userlevel 7
Badge +11

Most Welcome @aaghaei  I’m glad that helped you on this!

Userlevel 2
Badge

@Naveen B I got your code, did a little bit of modification as follow to reach what I needed but credit all goes to you. I couldn’t really underestand what are all those styles that you declared (for example Current, Preview, ...). Can you pleae a little bit elaborate? Here is what I needed and works for me.

        #region Grid Style
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;

//ForeColor
PXStyle foreColorGreen = new PXStyle();
foreColorGreen.ForeColor = System.Drawing.Color.Green;
page.Header.StyleSheet.CreateStyleRule(foreColorGreen, page, ".CssForeColorGreen");

PXStyle foreColorBlue = new PXStyle();
foreColorBlue.ForeColor = System.Drawing.Color.Blue;
page.Header.StyleSheet.CreateStyleRule(foreColorBlue, page, ".CssForeColorBlue");

PXStyle foreColorRed = new PXStyle();
foreColorRed.ForeColor = System.Drawing.Color.Red;
page.Header.StyleSheet.CreateStyleRule(foreColorRed, page, ".CssForeColorRed");


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

if (data.Status == EPStatuses.Approved)
{
erdb.Row.Style.CssClass = "CssForeColorGreen";
}
else if (data.Status == EPStatuses.Rejected)
{
erdb.Row.Style.CssClass = "CssForeColorRed";
}
else if (data.Status == EPStatuses.Routed)
{
erdb.Row.Style.CssClass = "CssForeColorBlue";
}
};
}
#endregion

 

Userlevel 7
Badge +11

@aaghaei Thanks a lot again! :)

Those are all the CSS Styles I have added for some color coding, I think you can ignore all of those and have a code what is required.

 

Userlevel 2
Badge

​​​@Naveen B I followed all of the instructions. On one of my grids (ApprovalLogGrid) styling works but the other one (ApprovalGrid) doesn’t work. Both of these grids are in one screen. The only difference is the grid doesn’t accept the styling is Acumatica’s own grid but I have added the other one myself in a tab item. Below I have provided my full Graph extension and Page code. Can you please help me figure out what I’m doing wrong and how I can fix this?

Graph:

        #region Grid Style
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;

//ForeColor
PXStyle foreColorGreen = new PXStyle();
foreColorGreen.ForeColor = System.Drawing.Color.Green;
page.Header.StyleSheet.CreateStyleRule(foreColorGreen, page, ".CssForeColorGreen");

PXStyle foreColorBlue = new PXStyle();
foreColorBlue.ForeColor = System.Drawing.Color.Blue;
page.Header.StyleSheet.CreateStyleRule(foreColorBlue, page, ".CssForeColorBlue");

PXStyle foreColorRed = new PXStyle();
foreColorRed.ForeColor = System.Drawing.Color.Red;
page.Header.StyleSheet.CreateStyleRule(foreColorRed, page, ".CssForeColorRed");


PX.Web.UI.PXGrid approvalGridWithStyle = (PX.Web.UI.PXGrid)ControlHelper.FindControl("ApprovalGrid", page);
if (approvalGridWithStyle != null)
{
approvalGridWithStyle.RowDataBound += (object grdsender, PXGridRowEventArgs erdb) =>
{
var data = erdb.Row.DataItem as EPApproval;
if (data != null)
{
if (data.Status == EPStatuses.Approved)
{
erdb.Row.Style.CssClass = "CssForeColorGreen";
}
else if (data.Status == EPStatuses.Rejected)
{
erdb.Row.Style.CssClass = "CssForeColorRed";
}
else if (data.Status == EPStatuses.Routed)
{
erdb.Row.Style.CssClass = "CssForeColorBlue";
}
}
else
{
return;
}
};
}


PX.Web.UI.PXGrid approvalLogGridWithStyle = (PX.Web.UI.PXGrid)ControlHelper.FindControl("ApprovalLogGrid", page);
if (approvalLogGridWithStyle != null)
{
approvalLogGridWithStyle.RowDataBound += (object grdsender, PXGridRowEventArgs erdb) =>
{
var data = erdb.Row.DataItem as UDCTEPApprovalLog;
if (data != null)
{
if (data.Status == EPStatuses.Approved)
{
erdb.Row.Style.CssClass = "CssForeColorGreen";
}
else if (data.Status == EPStatuses.Rejected)
{
erdb.Row.Style.CssClass = "CssForeColorRed";
}
else if (data.Status == EPStatuses.Routed)
{
erdb.Row.Style.CssClass = "CssForeColorBlue";
}
}
else
{
return;
}
};
}
}
#endregion

and Page

<px:PXTabItem Text="Approvals" BindingContext="form" LoadOnDemand="True" RepaintOnDemand="True">
<Template>
<px:PXGrid runat="server" ID="ApprovalGrid" DataSourceID="ds" Width="100%" SkinID="DetailsInTab" NoteIndicator="True" Style="left: 0; top: 0;">
<AutoSize Enabled="True" />
<Mode AllowFormEdit="True" AllowRowSizing="True" AllowAddNew="False" AllowDelete="False" AllowUpdate="False" ></Mode>
<Levels>
<px:PXGridLevel DataMember="Approval">
<Columns>
<px:PXGridColumn DataField="ApprovedByID" Width="150px" />
<px:PXGridColumn Width="150px" DataField="ApproveDate" />
<px:PXGridColumn Width="80px" DataField="Status" AllowNull="False" AllowUpdate="False" RenderEditorText="True" />
<px:PXGridColumn DataField="Reason" Width="740" />
</Columns>
</px:PXGridLevel>
</Levels>
<Layout WrapText="True" />
</px:PXGrid>
</Template>
</px:PXTabItem>

<px:PXTabItem Text="Approvals Log" BindingContext="form" LoadOnDemand="True" RepaintOnDemand="True">
<Template>
<px:PXGrid runat="server" ID="ApprovalLogGrid" DataSourceID="ds" Width="100%" SkinID="DetailsInTab" NoteIndicator="True" Style='left: 0; top: 0;'>
<AutoSize Enabled="True" />
<Mode AllowAddNew="False" AllowUpdate="False" AllowDelete="False" AllowFormEdit="True" AllowRowSizing="True" />
<Levels>
<px:PXGridLevel DataMember="ApprovalLogView">
<Columns>
<px:PXGridColumn DataField="ApprovedByID" Width="150px" AllowNull="" AllowUpdate="" />
<px:PXGridColumn DataField="ApproveDate" Width="150px" SyncVisible="" />
<px:PXGridColumn DataField="Status" RenderEditorText="True" Width="80px" AllowNull="False" AllowUpdate="False" />
<px:PXGridColumn DataField="Reason" Width="740" />
</Columns>
</px:PXGridLevel>
</Levels>
<Layout WrapText="True" />
</px:PXGrid>
</Template>
</px:PXTabItem>

 

Userlevel 7
Badge +11

Hi @aaghaei  Everything seems to be good for me.

Have you debugged and able to get the values in the below object?

 

PX.Web.UI.PXGrid approvalGridWithStyle = (PX.Web.UI.PXGrid)ControlHelper.FindControl("ApprovalGrid", page);

Userlevel 2
Badge

@Naveen B yes, please see below snip

 

Userlevel 7
Badge +11

@aaghaei  Even I’m not sure, system is trying to apply the colors for only one grid.

 

Can you please move approvalLogGridWithStyle logic above then have code for approvalGridWithStyle and check colors are applying for only approvalGridWithStyle grid?

Userlevel 2
Badge

@Naveen B I had thought the same before. So for testing I removed the “approvalLogGridWithStyle” to only have one styling in the page but the ApprovalGrid style didn’t change. Rigth now I tested what you asked but nothing changed.

The funny thing is I’m doing the same on one of Acumatica’s other standard screens “Approvals” to color code different document types awaiting for approval and it works.

Userlevel 2
Badge

Hi @Naveen B I was wondering did you have any chance to look into this a little bit deeper. The page and graph code can be copied into the AP Bills and Adjustments as is for testing. Just ignore the Log grid and C#.

This is attacker

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2020  Acumatica, Inc. All rights reserved