Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1960
HeaderStyleDefault.CssClass not working when TemplatedColumn is present.
posted

Hello,

First of all, I'm attaching a VS2008 project to reproduce the issue.

I want my grid to get the styles from a css. In order to do that I created my classes "GridRow" and "GridHeader". Then I set the RowStyleDefault.CssClass and HeaderStyleDefault.CssClass to the corresponding classes.

Test number one: Add one templated column and one normal column (those columns are already present on the attached project). When the page runs the header does not use the GridHeader class. It inherits the properties from GridRow instead. That's wrong.

Test number two: Now remove the templated column, run the page again. This time the header is only using the GridHeader class. That's the behavior I'm expecting.

Test number three: Add the templated column again, remove the RowStyleDefault.CssClass property, set RowStyleDefault.BackColor = White. Run the page, the header is using the the GridHeader class, which is the correct behavior.

It looks like the presence of the templated column affects the assignment of css classes.

Has anyone else noticed this problem?

HeaderStylesheetIssue.zip
Parents
No Data
Reply
  • 28464
    posted

    Hello Oscar, 

    Thanks for dropping us a line and for the sample attached - much appreciated.

    In this case I believe this might be the expected behavior, at least that sounds logical to me. RowStyle/HeaderStyle is used only for computed columns and applied only there, but when you are using a Templated Column, you take care of the template inside (content and presentation), so you may need to take care of the Css classes there as well.

    Here is an example I derived from your project that worked fine for me: 

     <igtbl:TemplatedColumn BaseColumnName="CompanyName" IsBound="True" Key="CompanyName">
                            <HeaderTemplate>
                                <span class="GridHeader">
                                    Company Name Template
                                </span>
                            </HeaderTemplate>
                            <CellTemplate>
                                <span class="GridRow">
                                    <% Eval("CompanyName" %>
                                </span>
                            </CellTemplate>
                        </igtbl:TemplatedColumn>

    So basically, I am using your approach, however instead of Caption I am using the respective templates and applying style there.

    Hope this helps! 

Children