London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Remove folder icon from Filelist.ascx treeview

Vote:
 

Is there an easy way to remove the folder icon in treeview? It looks like it gets created into a <td> node in a table and uses this image: <img src="/App_Themes/Default/Images/ExplorerTree/FileTree/Folder.gif" alt="" style="border-width:0;" />

I want to remove the image and not have the <td> node in the table for the icon. Is that possible? Or would I have to create a custom treeview control and do it myself?

#52553
Aug 02, 2011 14:15
Vote:
 

The easist way to remove the icons is with a little CSS. If you want to change the way FileTree renders I would consider using Control Adapters for this.

Take a look at this article for more information: http://msdn.microsoft.com/en-us/magazine/cc163543.aspx, I also recommend taking a look at the CSS Adapter project for some good example on how this is done.

Hope this helps.

Frederik

#52556
Aug 02, 2011 22:52
Vote:
 

Thanks Frederik! I appreciate the advice. I didn't know about Control Adapters, this is definitely something I can use if I want to render the table differently. I'll take a look and see what I can do with the FileTree. I actually found another way to handle my problem.

After digging a little, I did find that you can remove the whole column all together by removing the ImageUrlField property from TreeNodeBinding.

<asp:TreeNodeBinding TextField="Name" ToolTipField="Title" ImageUrlField="ImageUrl" PopulateOnDemand="true" />

But it also removed the document icon (pdf, excel, word, etc.) and that's not what I wanted. So, I found that instead of removing that column all together, I could replace the icon with another image. I added the event OnResolveDirectoryImageUrl and replaced the image in the event. This seemed to work better for me.

<EPiServer:FileSystemDataSource ID="FileDataSource" OnResolveDirectoryImageUrl="FileDataSource_OnResolveDirectoryImageUrl" IncludeRoot="true" runat="server" />
protected void FileDataSource_OnResolveDirectoryImageUrl(object sender, ResolveDirectoryImageArgs e)
        {
            string iconURL = HttpContext.Current.Request.Url.Scheme.ToString() + "://" + HttpContext.Current.Request.Url.Host.ToString() + "/Global/images/bullet_doublearrow.gif";
            if (iconURL != null || iconURL != "") { e.ImageUrl = iconURL; }
        }
#52569
Aug 03, 2011 13:50
Vote:
 

Also to add a little more control over whether I want to still use the original styling with the folder icon, I added a Selected/Not Selected Propety of "Apply New Style", and I check to see if it is checked (True). If it is True, then apply my new style and replace the folder icon with my icon.

#52570
Aug 03, 2011 13:55
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.