【问题标题】:Acumatica Styling a specific column in PXGrid?Acumatica 为 PXGrid 中的特定列设置样式?
【发布时间】:2017-07-14 17:16:59
【问题描述】:

我正在尝试为 PXGrid 中的列定义 Css 样式。

 <px:PXGrid ID="grid" runat="server" DataSourceID="ds" Width="100%"
                    TabIndex="100" SkinID="DetailsInTab" StatusField="Availability" SyncPosition="True" Height="473px" OnColumnDataBound="grid_rowBound">


protected void grid_rowBound(object sender, PX.Web.UI.PXGridRowEventArgs e)
{
    Object value = e.Row.Cells["OrigQty"].Value;
    if (value != null && ((Boolean)value) == false)
        e.Row.Style.CssClass = "RedCol";
}

是否可以使用 OnColumnDataBound 设置列样式?

【问题讨论】:

    标签: c# asp.net acumatica


    【解决方案1】:

    您可以在后面的页面代码中动态创建样式,如下所示。

    在下面的示例中,我修改了开箱即用的EP503010 页面。

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

    并在PXGridOnRowDataBound 事件处理程序中使用它,如下所示

    protected void grid_RowDataBound(object sender, PX.Web.UI.PXGridRowEventArgs e)
    {
        EPApprovalProcess.EPOwned item = e.Row.DataItem as EPApprovalProcess.EPOwned;
        if (item == null) return;
        if (item.Escalated == true)
        {
            //For Row - change the Font to Red
            e.Row.Style.CssClass = "CssEscalated";
        }
        else if (item.CuryTotalAmount.HasValue && item.CuryTotalAmount.Value > 10m)
        {
            //For Row - change the background to Red
            e.Row.Style.CssClass = "CssRowStyle";
        }
    
        //For Specific Column - change the background to Aqua - Whole Column all row.
        e.Row.Cells["Descr"].Style.CssClass = "CssCellStyle";
    
        //Conditional a specific column cell
        if (item.CuryTotalAmount.HasValue && item.CuryTotalAmount.Value > 10m)
        {
            e.Row.Cells["CuryTotalAmount"].Style.CssClass = "CssHighlightStyle";
        }
    }
    

    您可以参考开箱即用的 EP503010.aspx 和 EP503010.aspx.cs 页面文件。

    【讨论】:

    • 如何将 CSS 样式应用于整个列。
    • @nickivey 我已经修改了原来的答案。
    • 有谁知道是否可以将相同的技术应用于屏幕标题单元格?例如,如果我想突出显示 AR303000 中 Form 列下的列中的一个单元格?我对您可以在 Acumatica 中使用的所有类定义都不是很熟悉。
    猜你喜欢
    • 1970-01-01
    • 2012-01-06
    • 2013-09-18
    • 1970-01-01
    • 2022-08-11
    • 2017-03-25
    • 2011-03-17
    • 1970-01-01
    • 2014-12-06
    相关资源
    最近更新 更多