10,000 Monkeys - Harnessing the Power of Typing Monkeys

America's 2,672,401st Most Read Blog by Kevin Marshall.
in

Stylish CSS Gridviews (in IE)

I'm a huge fan a well designed GUIs and clean looking layouts, thats why I use a Mac <g>. While its easy to get the layout you want in a desktop application, its not always so easy in a web application. Even though IE frequently annoys me with its lack of standard CSS support, ocassionally it allows you to make some nice UI effects. One example is freezing headers in a grid view or table. In IE its pretty easy to do by wrapping the gridview in a div and setting a style on the header elements like so:

th 
{
    background-color: #006699; 
    color: white; 
    position: relative; 
    top: expression(this.scrollTop);
    z-index: 10; 
}
.tableContainer
{
    overflow-y: scroll; 
    height: 250px;
}
<div class="tableContainer">
    
<table class="table" cellpadding="0" cellspacing="0">
        
<tr>
            
<th>Name</th>    
        
</tr>
        ..........
    
</table>
</div>

This creates a scrollbar on the side of the table and keeps the headers in place as you scroll. Another nice effect which compliments the frozen headers is the rounded corners css style at Nifty Corners. You can check out the javascript/css code there which adds rounded edges to elements without images. By wrapping the tableContainer div in an extra roundCorners div, you can get something like this:

I posted a sample of the code used to create this screenshot here. Again this looks way cooler in IE 6+. It works fine in firefox, the headers just don't stay in place. Perhaps as CSS standards progress it'll be way easier to do all of this. Oh and all the browsers have to actually support CSS standards. IE, I'm looking in your direction.

Posted: Feb 23 2006, 08:15 AM by kmarshall | with 1 comment(s)
Filed under:

Comments

svemula said:

Nice article. I had a similar experience where I needed a similar functionality for ASP Datagrid. You can read about it at:

http://blogs.claritycon.com/blogs/satish_vemula/archive/2006/02/23/235.aspx

CSS is awesome!

Satish
# February 23, 2006 10:01 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)