Andrew Stopford's Weblog

poobah

Sponsors

News

Articles

Family

Old Blogs

A better treeview, using.....the treeview

After running into the display issue with the treeview and display issues in FF I was looking around for an answer and came across CssAdapters for ASP.NET. This project (currently in beta but would be great to see released) allows you to adapt how controls render, for example treeviews render as tables (which explains the cross over issues with panels and FF) but using this you can adapt to use CSS instead. The installer installs a asp.net template into VS and you can use that website project as the basis for your adaptions. It's wrapped up in masterpages and sitetemplates so if your not using those then you will need to do the following.

  • Copy the JavaScript folder over to your site as is
  • Copy the arrow, blank, collapse, expand graphic files and TreeView.css, TreeViewExample.css files from the template folder to your site.
  • Copy the Adapters folder in the App_Code folder to your sites App_Coder as is.

You will need to adapt your treeview as well, if your not using skins then you will need to alter the treeview with

 <asp:TreeView ID="TreeView" Runat="server" ExpandDepth="4" CollapseImageUrl="collapse.gif" ExpandImageUrl="expand.gif" NoExpandImageUrl="blank.gif" CssClass="TreeView-Skin-Root" CssSelectorClass="PrettyTree">

<RootNodeStyle CssClass="TreeView-Skin-Node" BorderStyle="solid" BorderWidth="1px" BorderColor="#E7E7E7" />

<ParentNodeStyle CssClass="TreeView-Skin-Node" BorderStyle="solid" BorderWidth="1px" BorderColor="#E7E7E7" />

<LeafNodeStyle ImageUrl="arrow.png" CssClass="TreeView-Skin-Leaf" />

</asp:TreeView>

Here note the CollapseImageUrl, ExpandImageUrl, NoExpandImageUrl, CssClass and the CssSelectorClass. This last attribute is added by the adapter.

Posted: Aug 31 2006, 12:09 PM by astopford | with 3 comment(s)
Filed under:

Comments

Karl said:

For $249 USD, you can buy a full-featured treeview from Telerik or ComponentArt. Not only are they fully cross-browser friendly, but they come loaded with a bunch of other goodies - and you'll be up and running with them within minutes.

The $249 probably has a much greater return than spending your own time on it.

# August 31, 2006 8:05 AM

astopford said:

Thanks for the head-up Karl however this kit does the job for my needs and it's a freebie.

# August 31, 2006 12:03 PM

astopford said:

It is worth mentioning that the cssadpters are going to break a lot of properties e.g.

http://forums.asp.net/thread/1285603.aspx

This could prevent you from using them.

# September 1, 2006 12:06 PM