I have a requirement to set color for the grid column filed based on condition. For example: I have two fields in grid 1. Sales Price 2. New Sales I want to show Green color if Sales price and New Sales value is same else want to show red color if Sales price is higher than New Sales else want to show Yellow color if Sales price is lower than New Sales.
This is not a generic inquiry screen, this is like processing screen using FormDetal Template in header i have some filter values based on that my grid data will get load on that i will modify price fields as mention above example "New Sales" field i will modify and it is unbound field "Sales" field is bound
so in the line item of grid if modify new sales then need to compare sales and New sales if both value are same then particularly for the NewSales field i need to show Green color.
I tried below code in my page file, but when i debug it didn't call this grid1_RowDataBound event
protected void Page_Load(object sender, EventArgs e)
{
//Create needed styles here
Style style = new Style();
style.Font.Bold = true;
this.Page.Header.StyleSheet.CreateStyleRule(style, this, "." + "BoldText");
Style style1 = new Style();
style1.ForeColor = System.Drawing.Color.FromArgb(50, 180, 50);
this.Page.Header.StyleSheet.CreateStyleRule(style1, this, "." + "GreenColor");
}
protected void grid1_RowDataBound(object sender, PX.Web.UI.PXGridRowEventArgs e)
{
// Take DataItem and convert it to your DAC object type
// KWUpdateStylePricing is my DAC name
KWUpdateStylePricing row = e.Row.DataItem as KWUpdateStylePricing;
if (row != null && row.WholeSalePrice == row.NewWholeSalePrice)
{
e.Row.Style.CssClass = "GreenColor";
}
}
Aspx page Grid properties
<px:PXGrid ID="grid1" runat="server" DataSourceID="ds" Style="z-index: 100; left: 0px; top: 0px; height: 385px;" Width="100%" NoteIndicator="false" FilesIndicator="false"
BorderWidth="0px" OnRowDataBound="grid1_RowDataBound" SkinID="DetailsInTab" SyncPosition="True" StatusField="MyAvailability" RepaintColumns="true" Height="385px" TabIndex="7700" AllowPaging="true" AdjustPageSize="Auto" AllowSearch="true" AllowAutoHide="false">
Thanks in advance.