Welcome Guest Search | Active Topics | Sign In | Register

Grid column does not keep style Options
TH
Posted: Wednesday, March 6, 2013 12:25:29 PM
Rank: Newbie
Groups: Member

Joined: 2/26/2013
Posts: 7
Hello,

I have a grid with 3 static columns which I create dynamically (code behind).
I assign styles (MyColumn.CellStyle.CssClass="xyz") to each column; they differ slightly per column.

The grid looks as desired, but not for long.

After the 2nd(!) postback the grid columns lose the style.
The styles fall back to the generic CellStyle as defined in the "_Default"-StyleSet.

I found a similar topic here:
http://www.essentialobjects.com/forum/postst6882_Grid-not-keeping-style-of-ButtonColumn-and-How-to-colour-cells-dependent-on-row-and-column-value.aspx

Question:
Is there something general I miss, or is there an issue?
(I am using V10.0.47.2 of EO.Web.DLL)

Thanks for any information,
Thilo
eo_support
Posted: Wednesday, March 6, 2013 12:54:45 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

Can you provide a test page so that we can use to reproduce the problem?

Thanks!
TH
Posted: Thursday, March 7, 2013 4:56:44 AM
Rank: Newbie
Groups: Member

Joined: 2/26/2013
Posts: 7
Here we go:

The ASPX page:
Code: HTML/ASPX
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Just a Test</title>
    <link rel="stylesheet" type="text/css" href="/my.css" media="all" />
</head>
<body>
    <form id="form1" runat="server">
    <div id="content">
        TEST TEST TEST
        <asp:Button ID="Button1" runat="server" Text="Update" />
        <br />         

        <eo:Grid ID="Grid1" runat="server" BorderColor="Purple" BorderWidth="1px" 
            FixedColumnCount="1" FixedTopItemCount="1"
            Font-Bold="False" 
            Font-Italic="False" Font-Names="Tahoma" Font-Overline="False" 
            Font-Size="8pt" Font-Strikeout="False" Font-Underline="False" 
            GridLineColor="220, 223, 228" GridLines="Both" 
            Height="200px" Width="380px"
            ItemHeight="15" ColumnHeaderDividerImage="/gridcoldivider.gif" 
            >
            <ItemStyles>
                <eo:GridItemStyleSet StyleSetID="_Default">
                    <ItemStyle CssClass="gridItem" />
                    <FixedColumnCellStyle CssClass="gridFixedColumnCell"/>
                    <CellStyle CssClass="gridCell" />
                </eo:GridItemStyleSet>
            </ItemStyles>
            <ColumnHeaderStyle CssClass="gridColumnHeader"/>
            <Columns>
            </Columns>
        </eo:Grid>
    </div>
    </form>
</body>
</html>


The code behind:
Code: C#
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //add grid columns
                StaticColumn col = new StaticColumn();
                col.HeaderText = "&lt;span style=\"float:left; text-align:left; padding:2px;\"&gt;Header&lt;/span&gt;";
                col.DataField = "Header";
                col.Name = "Header";
                col.AllowResize = true;
                col.AllowSort = true;
                col.CellStyle.CssClass = "gridTextColumn";
                Grid1.Columns.Add(col);

                col = new StaticColumn();
                col.HeaderText = "&lt;span style=\"float:right; text-align:right; padding:2px;\"&gt;Metric&lt;/span&gt;";
                col.DataField = "Metric";
                col.Name = "Metric";
                col.AllowResize = true;
                col.AllowSort = true;
                col.DataFormat = "{0:N0}";
                col.CellStyle.CssClass = "gridNumColumn";
                Grid1.Columns.Add(col);

                col = new StaticColumn();
                col.HeaderText = "&lt;span style=\"float:right; text-align:right; padding:2px;\"&gt;Share&lt;/span&gt;";
                col.DataField = "Share";
                col.Name = "Share";
                col.AllowResize = true;
                col.AllowSort = true;
                col.DataFormat = "{0:P2}";
                col.CellStyle.CssClass = "gridNumColumn";
                Grid1.Columns.Add(col);

                //create a small 3 column table
                DataTable dt = new DataTable("Test");
                dt.Columns.Add("Header", typeof(string));
                dt.Columns.Add("Metric", typeof(int));
                dt.Columns.Add("Share", typeof(double));

                //add some rows
                for (int i = 0; i < 15; i++)
                {
                    DataRow r = dt.NewRow();
                    r[0] = string.Format("Header {0}", i);
                    r[1] = i;
                    r[2] = ((double)i) * 1.11;

                    dt.Rows.Add(r);
                }

                //Bind Data
                Grid1.DataSource = dt;
                Grid1.DataBind();
            }
        }


The CSS styles:
Code: CSS
/* Grid */
#content .gridItem {background-color: white; line-height:1;}
#content .gridFixedColumnCell {color:red; text-align:left; padding-left:2px; padding-top:0px;}
#content .gridCell {color:red;text-align:right; padding-right:2px; padding-top:0px;}
#content .gridColumnHeader {color:#3a3a3a; background-color:#eee; border:#aaa 1px solid; font-weight:bold;line-height:1}
#content .gridTextColumn {color:#3a3a3a; text-align:left; padding-left:2px; padding-top:0px;}
#content .gridNumColumn {color:#3a3a3a;text-align:right; padding-right:2px; padding-top:0px;}


As mentioned before, after the 2nd click on "Update" (postback) the style changes (color changes from dark grey to red).

hth,
Thilo
eo_support
Posted: Friday, March 8, 2013 3:02:05 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

We have posted a new build that should fix this problem. Please see your private message for the download location.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.