This is a migrated thread and some comments may be shown as answers.

Difference between HeaderStyle-Width attribute and HeaderStyle tag with Width attribute

1 Answer 107 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Rick asked on 17 Dec 2015, 07:45 PM

I see attributes HeaderStyle-xxxxx and ItemStyle-xxxxx in the grid column tag and I see a nested elements <HeaderStyle /> (in which I can also specify the column width) and <ItemStyle />. 

I used the column attribute mechanism to set width and wrap; later I find that the attribute specific width has been supplemented by <HeaderStyle Width="..." /> nested elements; I see the same for ItemStyle-Wrap="false" generating nested <ItemStyle Wrap="False" />.

When I change value in the column tag attribute and the nested tag is present, it's setting takes precedence.

So, a few questions:

- What is generating the nested tags?

- Is one or the other markup mechanism preferred?  (Given the very long list of column attributes, I can see for readability the nested tags might be preferable. However, when both exist, it's too easy to edit the attribute value in the column tag instead of the nested header or item style element which has final determination of the setting.

- If using the column tag attributes method is equivalent, is there a way to disable the self-generation of the nested tags?  (Or for auto-removing the redundant attribute from the column element tag.)


Rick Palazola

The Jackson Laboratory

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 25 Dec 2015, 12:48 PM
Hi Rick,

Generally, your assumptions are correct. However, this is not Telerik specific, it is a general ASP.NET behavior:
<asp:GridView ID="GridView1" runat="server" HeaderStyle-BackColor="Orange">
    <HeaderStyle BackColor="Blue" />

The visibility of the hyphenated main tag definitions of the properties is controlled by the following Attribute, which is usually added to the RadControlX.Public.cs file:
public ImageGalleryThumbnailsAreaSettings ThumbnailsAreaSettings

So it is up to your personal preference. As for the auto-generating of redundant nested tags, I am not sure what may cause it. Perhaps you are using some kind of Visual Studio designer generated code for configuring your RadGrid mark-up.

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question