2017-02-24 88 views
0

我試圖爲PXGrid中的列定義Css風格。Acumatica在PXGrid中設置特定的列?

<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實現列樣式?

回答

0

您可以在後面的頁面代碼中動態創建樣式,如下所示。

在下面的例子中,我已經修改了開箱即用的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"; 
    } 
} 

enter image description here

你可以參照出的現成EP503010.aspx & EP503010.aspx.cs頁文件。

+0

我將如何將CSS樣式應用於整個列。 – nickivey

+0

@nickivey我修改了原來的答案。 – DChhapgar

+0

謝謝你的作品! – nickivey