• Home
  • About
  • Resume

Correctly apply external styles to UltraWebGrid

By , 02/09/2012 5:44 PM

Classic Infragistics UltraWebGrid allows you to programmaticaly specify CSS styles for its various elements. For example code like this:

xmyGrid.DisplayLayout.HeaderStyleDefault.CssClass = "HeaderStyle"
xmyGrid.DisplayLayout.RowStyleDefault.CssClass = "RowStyle"

Would set style of grid header and rows via external CSS class. You would expect that simple defining classes like this:

.HeaderStyle {  /* style definition goes here */ }
.RowStyle {  /* style definition goes here */ }

should do the trick, but you may experience some unwanted, erratic behavior: styles getting lost, styles getting mixed up (row would get a header style and vise versa).

To fix this we should let grid know that header style should apply only to header row (THEAD/TH HTML elements) and row style applies only to rows with data (TBODY/TD elements). This is done via slight adjustments of the above CSS to point it to specific elements:

THEAD.HeaderStyle TR TH{  /* style definition goes here */ }
TBODY.RowStyle TR TD {  /* style definition goes here */ }

This way there’s no confusion, styles apply exactly were they belong. Also you may need to set grids MergeStyles property to False and make each class fully define it’s element (including fonts, colors, backgrounds etc.)

2 Responses to “Correctly apply external styles to UltraWebGrid”

  1. Amir says:

    Thank you *so much!* for taking the time to write and post this article. It described my problem exactly and it helped me fix it. Thank you so much, again, for posting!

  2. Yuriy says:

    @Amir you’re welcome, glad I was able to help. This is exactly why I am not keeping these findings to myself, so the others can benefit as well

Leave a Reply

Panorama Theme by Themocracy