我正在尝试为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可以进行列样式化吗?
答案 0 :(得分: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");
}
并在OnRowDataBound
的{{1}}事件处理程序中使用它,如下所示
PXGrid
您可以参考开箱即用的EP503010.aspx&amp; EP503010.aspx.cs页面文件。