Acumatica 在 PXView 中设置特定列/单元格的样式?

发布于 2025-01-09 04:06:09 字数 2587 浏览 1 评论 0原文

我对 Acumatica 编码非常陌生。我正在尝试更改 AR303000 标题页上单元格的颜色。 (参见下面的代码)。显然这是行不通的。我收到错误消息 PXFormViewEventArgs 在命名空间 PX.Web.UI 中不存在。
谁能指导我应该使用哪个命名空间并更正我的代码以使其工作? 谢谢你,

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using PX.Common;
using PX.Data;
using PX.SM;
using PX.Objects.AR.CCPaymentProcessing;
using PX.Objects.AR.Repositories;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.CA;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CR.Extensions;
using PX.Objects.CS;
using PX.Objects.SO;
using PX.Objects.AR.CCPaymentProcessing.Helpers;
using PX.Data.BQL.Fluent;
using PX.Data.BQL;
using PX.Data.Descriptor;
using CashAccountAttribute = PX.Objects.GL.CashAccountAttribute;
using PX.Objects.GL.Helpers;
using PX.Objects.TX;
using PX.Objects.IN;
using PX.Objects.CR.Extensions.Relational;
using PX.Objects.CR.Extensions.CRCreateActions;
using PX.Objects.GDPR;
using PX.Objects.GraphExtensions.ExtendBAccount;
using PX.Data.ReferentialIntegrity.Attributes;
using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Objects;
using PX.Objects.AR;

namespace PX.Objects.AR
{
  public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
  {
  

    protected void Page_Load(object sender, EventArgs e)
    {
      Style escalated = new Style();
      escalated.ForeColor = System.Drawing.Color.Red;
      this.Page.Header.StyleSheet.CreateStyleRule(escalated, this, ".CssEscalated");

      Style rowStyle = new Style();
      rowStyle.BackColor = System.Drawing.Color.Red;
      this.Page.Header.StyleSheet.CreateStyleRule(rowStyle, this, ".CssRowStyle");

      Style cellStyle = new Style();
      cellStyle.BackColor = System.Drawing.Color.Aqua;
      this.Page.Header.StyleSheet.CreateStyleRule(cellStyle, this, ".CssCellStyle");

      Style highlightStyle = new Style();
      highlightStyle.BackColor = System.Drawing.Color.Yellow;
      this.Page.Header.StyleSheet.CreateStyleRule(highlightStyle, this, ".CssHighlightStyle");
  
    }
    
    protected void Customer_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PX.Web.UI.PXFormViewEventArgs f)
      {
        var customer = (CR.BAccount)e.Row;
        var customerExt = customer.GetExtension<CR.BAccountExt>();
        if (customerExt != null)
          {
            /*I want to change the color of this cell in the form*/
            customerExt.UsrReadOnlyAcctName = customer.AcctName;
          }
      }
  
    #region Event Handlers

    #endregion
  }
}```

I am VERY new to Acumatica in coding. I am trying to change the color of a cell on the header page of AR303000. (see code below). Obviously this is not working. I receive the error message of PXFormViewEventArgs does not exist in the namespace PX.Web.UI.
Can anyone direct me as to what namespace I should be using and correct my code to make this work?
Thank you,

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using PX.Common;
using PX.Data;
using PX.SM;
using PX.Objects.AR.CCPaymentProcessing;
using PX.Objects.AR.Repositories;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.CA;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CR.Extensions;
using PX.Objects.CS;
using PX.Objects.SO;
using PX.Objects.AR.CCPaymentProcessing.Helpers;
using PX.Data.BQL.Fluent;
using PX.Data.BQL;
using PX.Data.Descriptor;
using CashAccountAttribute = PX.Objects.GL.CashAccountAttribute;
using PX.Objects.GL.Helpers;
using PX.Objects.TX;
using PX.Objects.IN;
using PX.Objects.CR.Extensions.Relational;
using PX.Objects.CR.Extensions.CRCreateActions;
using PX.Objects.GDPR;
using PX.Objects.GraphExtensions.ExtendBAccount;
using PX.Data.ReferentialIntegrity.Attributes;
using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Objects;
using PX.Objects.AR;

namespace PX.Objects.AR
{
  public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
  {
  

    protected void Page_Load(object sender, EventArgs e)
    {
      Style escalated = new Style();
      escalated.ForeColor = System.Drawing.Color.Red;
      this.Page.Header.StyleSheet.CreateStyleRule(escalated, this, ".CssEscalated");

      Style rowStyle = new Style();
      rowStyle.BackColor = System.Drawing.Color.Red;
      this.Page.Header.StyleSheet.CreateStyleRule(rowStyle, this, ".CssRowStyle");

      Style cellStyle = new Style();
      cellStyle.BackColor = System.Drawing.Color.Aqua;
      this.Page.Header.StyleSheet.CreateStyleRule(cellStyle, this, ".CssCellStyle");

      Style highlightStyle = new Style();
      highlightStyle.BackColor = System.Drawing.Color.Yellow;
      this.Page.Header.StyleSheet.CreateStyleRule(highlightStyle, this, ".CssHighlightStyle");
  
    }
    
    protected void Customer_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PX.Web.UI.PXFormViewEventArgs f)
      {
        var customer = (CR.BAccount)e.Row;
        var customerExt = customer.GetExtension<CR.BAccountExt>();
        if (customerExt != null)
          {
            /*I want to change the color of this cell in the form*/
            customerExt.UsrReadOnlyAcctName = customer.AcctName;
          }
      }
  
    #region Event Handlers

    #endregion
  }
}```

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜你已久 2025-01-16 04:06:09

我认为你可以检测Form和UsrReadonlyAcctName的控件,然后在Page_Load期间应用Css样式;下面是一个示例,但就我而言,我找到一个网格,然后在 RowDataBound 期间检测单元格的值:

     public override void Initialize()
    {
        //Access page via http context current handler
        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;

        RegisterStyle(page, "MyCssRed", "#FD9999 !important", null, false);

        PX.Web.UI.PXGrid grdMyGridControl = (PX.Web.UI.PXGrid)ControlHelper.FindControl("grid2", page);  // Allocations popup

        if (grdMyGridControl != null)
        {
            grdMyGridControl.RowDataBound += (object grdsender, PXGridRowEventArgs erdb) =>
            {
                var data = erdb.Row;
                if (data == null) { return; }
                bool isRed = false;

                PXGridCell cell = data.Cells["INItemLotSerialKvExt__ValueString"];
                if (cell == null) return;
                Object value = cell.Value;
                if (value != null && (String)value == "R")
                {
                    isRed = true;
                }
                
                ...
                                
                if (isRed)
                        data.Style.CssClass = "MyCssRed";
                

Patrick Chen 提供了有用的参考。

编辑答案:

下面是销售订单页面 SO301000 上的示例,该示例查找“客户订单编号”文本框并在其文本为空时添加颜色:

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

        RegisterStyle(page, "MyCssRed", "#FD9999 !important", null, false);

        PX.Web.UI.PXTextEdit myBox = (PX.Web.UI.PXTextEdit)ControlHelper.FindControl("edCustomerOrderNbr", page);

        if (myBox != null)
        {
            myBox.DataBinding += (object boxsender, EventArgs boxargs) =>
            {
                PX.Web.UI.PXTextEdit box = boxsender as PX.Web.UI.PXTextEdit;
                string cellText = box.Text;
                box.CssClass = string.IsNullOrEmpty(cellText) ? "MyCssRed" : "editor";
            };
        }

I think you can detect the Form and the control of the UsrReadonlyAcctName and then apply the Css style during Page_Load; below is an example, but in my case, I find a Grid and then detect a Cell's value during RowDataBound:

     public override void Initialize()
    {
        //Access page via http context current handler
        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;

        RegisterStyle(page, "MyCssRed", "#FD9999 !important", null, false);

        PX.Web.UI.PXGrid grdMyGridControl = (PX.Web.UI.PXGrid)ControlHelper.FindControl("grid2", page);  // Allocations popup

        if (grdMyGridControl != null)
        {
            grdMyGridControl.RowDataBound += (object grdsender, PXGridRowEventArgs erdb) =>
            {
                var data = erdb.Row;
                if (data == null) { return; }
                bool isRed = false;

                PXGridCell cell = data.Cells["INItemLotSerialKvExt__ValueString"];
                if (cell == null) return;
                Object value = cell.Value;
                if (value != null && (String)value == "R")
                {
                    isRed = true;
                }
                
                ...
                                
                if (isRed)
                        data.Style.CssClass = "MyCssRed";
                

Patrick Chen supplies a helpful reference.

EDIT ANSWER:

Below is an example on the Sales Order page SO301000 that finds the "Customer Order Nbr" TextBox and adds color when its Text is empty:

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

        RegisterStyle(page, "MyCssRed", "#FD9999 !important", null, false);

        PX.Web.UI.PXTextEdit myBox = (PX.Web.UI.PXTextEdit)ControlHelper.FindControl("edCustomerOrderNbr", page);

        if (myBox != null)
        {
            myBox.DataBinding += (object boxsender, EventArgs boxargs) =>
            {
                PX.Web.UI.PXTextEdit box = boxsender as PX.Web.UI.PXTextEdit;
                string cellText = box.Text;
                box.CssClass = string.IsNullOrEmpty(cellText) ? "MyCssRed" : "editor";
            };
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文