您可以在後面的頁面代碼中動態創建樣式,如下所示。
在下面的例子中,我已經修改了開箱即用的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");
}
,並使用在PXGrid
OnRowDataBound
事件處理程序如下
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
@nickivey我修改了原來的答案。 – DChhapgar
謝謝你的作品! – nickivey