<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>To The Point &#187; Navigation</title>
	<atom:link href="http://sharepoint.inproc.com/category/navigation/feed/" rel="self" type="application/rss+xml" />
	<link>http://sharepoint.inproc.com</link>
	<description>Tom Dietz&#039;s Musings on SharePoint and .NET Development</description>
	<lastBuildDate>Fri, 29 Jan 2010 19:44:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating Mega Drop Down Navigation in SharePoint with jQuery &#8211; Part 2</title>
		<link>http://sharepoint.inproc.com/creating-mega-drop-down-navigation-in-sharepoint-with-jquery-part-2/</link>
		<comments>http://sharepoint.inproc.com/creating-mega-drop-down-navigation-in-sharepoint-with-jquery-part-2/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 18:06:24 +0000</pubDate>
		<dc:creator>tdietz</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Navigation]]></category>
		<category><![CDATA[CSS.MegaDropDown]]></category>
		<category><![CDATA[Mega Drop Down]]></category>

		<guid isPermaLink="false">http://sharepoint.inproc.com/?p=142</guid>
		<description><![CDATA[This is part two in a three part series for implementing Mega Drop Down navigation in SharePoint 2007.&#160; The topics covered are: Part 1 – Tables, Unordered Lists, and SharePoint Part 2 – Custom Control Rendering Part 3 – Hooking it all up with jQuery Since the out-of-the-box SharePoint menu control renders the HTML in [...]]]></description>
			<content:encoded><![CDATA[<p>This is part two in a three part series for implementing Mega Drop Down navigation in SharePoint 2007.&#160; The topics covered are:</p>
<p> <a href="http://tothepoint.inproc.com/creating-mega-drop-down-navigation-in-sharepoint-2007-with-jquery/">Part 1 – Tables, Unordered Lists, and SharePoint</a>   <br /><strong>Part 2 – Custom Control Rendering</strong>   <br />Part 3 – Hooking it all up with jQuery   </p>
<p>Since the out-of-the-box SharePoint menu control renders the HTML in &lt;TABLE&gt; elements,skinning and customizations are limited.&#160; The rendering for my MegaDropDown is based on the &lt;DIV&gt; and &lt;UL&gt; elements and provides many more customization options.&#160; <em>Note:&#160; In SharePoint 2010, the AspMenu control has an </em><a href="http://blog.drisgill.com/2009/11/sp2010-branding-tip-7-using-simple.html" target="_blank"><em>option to render</em></a><em> with &lt;UL&gt; based elements.&#160; I haven’t ported the MegaDropDown to SP2010 yet, but will post my results when I get a chance to convert it.</em></p>
<p>Once you bind to the navigation’s data source, you can easily walk through the collection of items and render HTML on the fly. I was doing this in my first iteration of the MDD, but things got a little complicated as I needed to parse all the available menu options, and then apply some custom jQuery logic once I had everything calculated.&#160; That said, I opted for a two pass approach:</p>
<p>Pass 1 – Iterate through the navigation data source and build my own customized collection that stored some extended properties that were specific to the MDD.</p>
<p>Pass 2 – Iterate through the custom collection and render the HTML</p>
<p>While there is obviously an extra step involved (and another copy of the navigation), it <strong>really</strong> simplified the code and the overall process.</p>
<p>The custom collection essentially consists of several container classes that keep track of the navigation items (Title, Url, Type).&#160; The first two properties are pretty obvious but Type is tailored for the MDD.&#160; Type determines if the item is a standard menu item or is an image.&#160; A benefit of the MDD is that is has the ability to display a site “image” within the navigation drop down itself (more on this later).</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ff86bd94-49ea-4ae5-ac51-9a234ed1deb6" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &quot;Courier New&quot;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li>[<span style="color: #2b91af">Serializable</span>] </li>
<li style="background: #f3f3f3"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> <span style="color: #2b91af">MenuItem</span> </li>
<li>{ </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Name; </li>
<li>&#160;&#160;&#160; <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Html; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Url; </li>
<li>&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">public</span> MenuItem() { } </li>
<li>&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">public</span> MenuItem(<span style="color: #0000ff">string</span> name, <span style="color: #0000ff">string</span> html, <span style="color: #0000ff">string</span> url) </li>
<li>&#160;&#160;&#160; { </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Name = name; </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; Html = html; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; Url = url; </li>
<li>&#160;&#160;&#160; } </li>
<li style="background: #f3f3f3">&#160; </li>
<li>&#160;&#160;&#160; <span style="color: #0000ff">public</span> <span style="color: #2b91af">MenuItemType</span> Type; </li>
<li style="background: #f3f3f3">}</li>
</ol></div>
</p></div>
</p></div>
<h4>Displaying and grouping items</h4>
<p>There are two formats for displaying menu items: standard and grouped.&#160; Standard is just what you would expect and menu items are rendered in the order defined in SharePoint.&#160; Grouped items however, allow you to organize links into categories which can significantly simplify the interface when needing to display dozens of links.&#160; A major requirement of the MDD project was to keep the customization as transparent and compatible with SharePoint as possible.&#160; The grouping logic is one place where some customizations are visible.&#160; In order to group items there needs to be a way to define the group name (i.e. category) as well as the links are associated with each category.&#160; </p>
<p><a href="http://sharepoint.inproc.com/wp-content/uploads/2010/01/NavUnGrouped.png" rel="lightbox" title="Navigation with ungrouped links"><img  title="Nav UnGrouped" border="0" alt="Nav UnGrouped" src="http://sharepoint.inproc.com/wp-content/uploads/2010/01/NavUnGrouped.png" /></a>
<p><strong><font color="#ff8000">MegaDropDown with uncategorized items</font></strong></p>
<p> <a href="http://sharepoint.inproc.com/wp-content/uploads/2010/01/NavGrouped.png" rel="lightbox" title="Navigation with grouped links"><img title="Nav Grouped" border="0" alt="Nav Grouped" src="http://sharepoint.inproc.com/wp-content/uploads/2010/01/NavGrouped.png"/></a>
<p><strong><font color="#ff8000">MegaDropDown with categorized items</font></strong></p>
<p>The client I was working with was very adamant about using the standard SharePoint &quot;Modify Navigation” UI so I am not entirely happy with the solution for grouping, but it does solve the problem without building any new web forms or pages.&#160; A special syntax was created so an admin simply has to enter it within the standard UI.&#160; When you want to specify that a link should fall within a specific group, you append the link title with $GroupName.&#160; For example, if you wanted to create a group named <strong>Offices</strong> and add the <strong>Chicago</strong> office, you would enter:</p>
<p>Chicago$Offices</p>
<p>That’s it.&#160; The parsing code will detect this and separate out the names automatically.&#160; Here’s how it would look in the Navigation Link dialog:</p>
<p><a href="http://sharepoint.inproc.com/wp-content/uploads/2010/01/image3.png" rel="lightbox" title="Navigation Link Dialog"><img title="Navigation Link Dialog" border="0" alt="image" src="http://sharepoint.inproc.com/wp-content/uploads/2010/01/image3.png" /></a> </p>
<p>As I said, I don’t exactly like the approach, but it is a pretty low-impact solution and took about 20 minutes to write the parsing code—and no UI changes were needed!</p>
<p>I keep track of each MenuItem in a generic List.&#160; Since there are two types of dropdowns (standard and grouped), I keep track of each link type in a separate List.&#160; </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0be9e58d-89b1-4456-a67b-cce7bc36e870" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &quot;Courier New&quot;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li>[<span style="color: #2b91af">Serializable</span>] </li>
<li style="background: #f3f3f3"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> <span style="color: #2b91af">MenuNode</span> : <span style="color: #2b91af">MenuItem</span> </li>
<li>{ </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">public</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">MenuGroup</span>&gt; Groups = <span style="color: #0000ff">new</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">MenuGroup</span>&gt;(); </li>
<li>&#160;&#160;&#160; <span style="color: #0000ff">public</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">MenuItem</span>&gt; Items = <span style="color: #0000ff">new</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">MenuItem</span>&gt;(); </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">public</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">MenuNode</span>&gt; Nodes = <span style="color: #0000ff">new</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">MenuNode</span>&gt;(); </li>
<li>&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">public</span> MenuNode() { } </li>
<li>&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">public</span> MenuNode(<span style="color: #0000ff">string</span> name, <span style="color: #0000ff">string</span> html, <span style="color: #0000ff">string</span> url) </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; : <span style="color: #0000ff">base</span>(name, html, url) </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; { </li>
<li>&#160;&#160;&#160; } </li>
<li style="background: #f3f3f3">&#160; </li>
<li>&#160;&#160;&#160; <span style="color: #0000ff">public</span> <span style="color: #2b91af">MenuState</span> State; </li>
<li style="background: #f3f3f3">}</li>
</ol></div>
</p></div>
</p></div>
<p>&#160;</p>
<p>Keeping track of all of the navigation types is a little tricky, so hopefully the following diagram helps illustrate how the collections relate:</p>
<p>Once all the parsing is done and I am ready to render the items, I simply iterate through each list and generate the HTML:&#160;&#160; For brevity, I’ve removed some of the housekeeping logic, but the RenderMenus() method walks the main List&lt;&gt; and calls RenderGroupItems or RenderMenuItems() accordingly:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:69b1e346-3fca-42fd-979d-a534855f8a92" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &quot;Courier New&quot;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #0000ff">private</span> <span style="color: #0000ff">bool</span> RenderMenus() </li>
<li style="background: #f3f3f3">{ </li>
<li>&#160;&#160;&#160; <span style="color: #0000ff">int</span> menuCount = 0; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">string</span> _menuItem = <span style="color: #a31515">&quot;&lt;li class=&#8217;menuitem{0}&#8217;&gt;&lt;a href=&#8217;{1}&#8217;&gt;&lt;span class=&#8217;menuitem{2}&#8217;&gt;{3}&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&quot;</span>; </li>
<li>&#160;&#160;&#160; <span style="color: #0000ff">string</span> _parentMenuItem = <span style="color: #a31515">&quot;&lt;li class=&#8217;nav_sites{0} menuitem{1}&#8217;&gt;&lt;a href=&#8217;{2}&#8217;&gt;&lt;span class=&#8217;groupmenuitem{3}&#8217;&gt;{4}&lt;/span&gt;&lt;/a&gt;&quot;</span>; </li>
<li style="background: #f3f3f3">&#160; </li>
<li>&#160;&#160;&#160; writer.Write(<span style="color: #a31515">&quot;&lt;ul id=&#8217;navigation&#8217;&gt;&quot;</span>); </li>
<li style="background: #f3f3f3">&#160; </li>
<li>&#160;&#160;&#160; <span style="color: #008000">// renders the top level menu (horizontal navigation bar)</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">foreach</span> (MenuNode node <span style="color: #0000ff">in</span> _menuNodes) </li>
<li>&#160;&#160;&#160; { </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">string</span> current = <span style="color: #0000ff">string</span>.Empty; </li>
<li>&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #008000">// if this site (or any sub-site within) is the current site, add a CSS style so we can hightlight it</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">if</span> (node.State == MenuState.MenuSelected) </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; current = <span style="color: #a31515">&quot; current&quot;</span>; </li>
<li>&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #008000">// just a single-level menu item (no kids)</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">if</span> ((node.Items.Count == 0) &amp;&amp; (node.Groups.Count == 0)) </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; { </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; output = <span style="color: #0000ff">string</span>.Format(_menuItem, current, node.Url, current, node.Name); </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; writer.Write(output); </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; } </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">else</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; { </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">if</span> (node.Groups.Count &gt; 0)&#160; <span style="color: #008000">// traverse all groups</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; output = <span style="color: #0000ff">string</span>.Format(_parentMenuItem, menuCount, current, node.Url, current, node.Name); </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; writer.Write(output); </li>
<li style="background: #f3f3f3">&#160; </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; RenderGroupItems(writer, node, menuCount); </li>
<li style="background: #f3f3f3">&#160; </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; writer.Write(<span style="color: #a31515">&quot;&lt;/li&gt;&quot;</span>); </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span> (node.Items.Count &gt; 0) </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; output = <span style="color: #0000ff">string</span>.Format(_parentMenuItem, menuCount, current, node.Url, current, node.Name); </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; writer.Write(output); </li>
<li>&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; scriptBlock = RenderMenuItems(writer, node.Items, menuCount); </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; scripts.Add(scriptBlock); </li>
<li style="background: #f3f3f3">&#160; </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; writer.Write(<span style="color: #a31515">&quot;&lt;/li&gt;&quot;</span>); </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } </li>
<li>&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; menuCount++; </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; } </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; } </li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
<h4>Rendering Menu Items</h4>
<p>For the most part, displaying each of the menu items involves the same logic except you iterate through each of the top level items menus.&#160; As you read each item, you just emit individual &lt;li&gt; elements that represent each of the menus. </p>
<p><a href="http://sharepoint.inproc.com/wp-content/uploads/2010/01/nav_gr2.jpg" rel="lightbox" title="Mega Drop Down Layout"><img  border="0" alt="nav_gr" src="http://sharepoint.inproc.com/wp-content/uploads/2010/01/nav_gr2.jpg" /></a> </p>
<p>The end result of the HTML might look something like this: </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:65f2daef-2853-463a-ab33-38d861d1aa83" class="wlWriterSmartContent"></div>
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &quot;Courier New&quot;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="padding-bottom: 2px; padding-left: 5px; padding-right: 5px; font-family: verdana, tahoma, arial, sans-serif; background: #000080; color: #fff; font-weight: bold; padding-top: 2px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #0000ff">&lt;</span><span style="color: #a31515">div</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;navcontainer&quot;&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">ul</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&#8217;navigation&#8217;&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">li</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;menuitem current&#8217;&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">a</span> <span style="color: #ff0000">href</span><span style="color: #0000ff">=&#8217;/Pages/Default.aspx&#8217;&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">span</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;menuitem current&#8217;&gt;</span>Home<span style="color: #0000ff">&lt;/</span><span style="color: #a31515">span</span><span style="color: #0000ff">&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">a</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">li</span><span style="color: #0000ff">&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">li</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;menuitem&#8217;&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">a</span> <span style="color: #ff0000">href</span><span style="color: #0000ff">=&#8217;/news&#8217;&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">span</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;menuitem&#8217;&gt;</span>News<span style="color: #0000ff">&lt;/</span><span style="color: #a31515">span</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">a</span><span style="color: #0000ff">&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">li</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">li</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;nav_sites0 menuitem&#8217;&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">a</span> <span style="color: #ff0000">href</span><span style="color: #0000ff">=&#8217;/locations&#8217;&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">span</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;groupmenuitem&#8217;&gt;</span>Locations<span style="color: #0000ff">&lt;/</span><span style="color: #a31515">span</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">a</span><span style="color: #0000ff">&gt;</span> </li>
<li style="background: #f3f3f3">&#160; </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">div</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&#8217;menu0&#8242;</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;menu&#8217;&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;menunavitems&#8217;</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&#8217;menunavitems_1&#8242;&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">table</span> <span style="color: #ff0000">cellpadding</span><span style="color: #0000ff">=&#8217;0&#8242;</span> <span style="color: #ff0000">cellspacing</span><span style="color: #0000ff">=&#8217;0&#8242;</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;navlinklayout&#8217;</span> <span style="color: #ff0000">width</span><span style="color: #0000ff">=&#8217;100%&#8217;</span> <span style="color: #ff0000">border</span><span style="color: #0000ff">=&#8217;0&#8242;&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">tr</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">td</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;grouplayout&#8217;</span> <span style="color: #ff0000">valign</span><span style="color: #0000ff">=&#8217;top&#8217;&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">h3</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;cat_header&#8217;&gt;</span>Offices<span style="color: #0000ff">&lt;/</span><span style="color: #a31515">h3</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">ul</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;sub_nav&#8217;</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&#8217;1&#8242;&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">li</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">a</span> <span style="color: #ff0000">href</span><span style="color: #0000ff">=&#8217;/offices/chicago&#8217;&gt;&lt;</span><span style="color: #a31515">span</span><span style="color: #0000ff">&gt;</span>Chcago<span style="color: #0000ff">&lt;/</span><span style="color: #a31515">span</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #a31515">a</span><span style="color: #0000ff">&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">li</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">li</span><span style="color: #0000ff">&gt;&lt;</span><span style="color: #a31515">a</span> <span style="color: #ff0000">href</span><span style="color: #0000ff">=&#8217;/offices/newyork&#8217;&gt;&lt;</span><span style="color: #a31515">span</span><span style="color: #0000ff">&gt;</span>New York<span style="color: #0000ff">&lt;/</span><span style="color: #a31515">span</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #a31515">a</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #a31515">li</span><span style="color: #0000ff">&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">ul</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">td</span><span style="color: #0000ff">&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">tr</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">table</span><span style="color: #0000ff">&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">div</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">div</span><span style="color: #0000ff">&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">li</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">li</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;menuitem&#8217;&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">a</span> <span style="color: #ff0000">href</span><span style="color: #0000ff">=&#8217;/reports&#8217;&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;</span><span style="color: #a31515">span</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8217;menuitem&#8217;&gt;</span>Reports<span style="color: #0000ff">&lt;/</span><span style="color: #a31515">span</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">a</span><span style="color: #0000ff">&gt;</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">li</span><span style="color: #0000ff">&gt;</span> </li>
<li>&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">&lt;/</span><span style="color: #a31515">ul</span><span style="color: #0000ff">&gt;</span> </li>
<li><span style="color: #0000ff">&lt;/</span><span style="color: #a31515">div</span><span style="color: #0000ff">&gt;</span></li>
</ol></div>
</p></div>
<p>&#160;</p>
<p>The code is fairly straightforward and I tried to make the HTML as simple as possible.&#160; The entire navigation, including the mega drop down sits inside the main &lt;div&gt; container ‘navcontainer’.&#160; The ‘navigation’ &lt;UL&gt; handles the horizontal top ‘tabbed’ navigation menu.&#160; Since it is &lt;UL&gt; based, I style the layout and appearance with CSS.&#160; Each &lt;LI&gt; represents a tab defined in SharePoint’s navigation page.&#160; </p>
<p>When sub-navigation items exists (e.g. sub-sites), a new &lt;DIV&gt; (menu) is defines the drop down itself.&#160;&#160; Although I tried to follow a flexible &lt;DIV&gt; based layout, the sub-items list is tabular and fits nicely in a &lt;TABLE&gt;.&#160;&#160; If grouping exists, each group (or category) is displayed with a styled &lt;H3&gt;.&#160; All the sub-items are then displayed with an embedded &lt;UL&gt; (sub-nav).</p>
<p>In my next and final article, I will explain how I hook it all up with jQuery.&#160; (I promise that it won’t be nearly as long between postings).</p>
<p>As always, comment or email me if you have any questions.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsharepoint.inproc.com%2Fcreating-mega-drop-down-navigation-in-sharepoint-with-jquery-part-2%2F&amp;title=Creating%20Mega%20Drop%20Down%20Navigation%20in%20SharePoint%20with%20jQuery%20%26%238211%3B%20Part%202" id="wpa2a_4"><img src="http://sharepoint.inproc.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsharepoint.inproc.com%2Fcreating-mega-drop-down-navigation-in-sharepoint-with-jquery-part-2%2F&amp;title=Creating%20Mega%20Drop%20Down%20Navigation%20in%20SharePoint%20with%20jQuery%20%26%238211%3B%20Part%202" id="wpa2a_6"><img src="http://sharepoint.inproc.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://sharepoint.inproc.com/creating-mega-drop-down-navigation-in-sharepoint-with-jquery-part-2/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Creating Mega Drop Down Navigation in SharePoint with jQuery &#8211; Part 1</title>
		<link>http://sharepoint.inproc.com/creating-mega-drop-down-navigation-in-sharepoint-2007-with-jquery/</link>
		<comments>http://sharepoint.inproc.com/creating-mega-drop-down-navigation-in-sharepoint-2007-with-jquery/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 04:56:07 +0000</pubDate>
		<dc:creator>tdietz</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[MOSS]]></category>
		<category><![CDATA[Navigation]]></category>

		<guid isPermaLink="false">http://tothepoint.inproc.com/2009/08/10/creating-mega-drop-down-navigation-in-sharepoint-2007-with-jquery/</guid>
		<description><![CDATA[This is part one in a three part series for implementing Mega Drop Down navigation in SharePoint 2007.&#160; The topics covered are: Part 1 – Tables, Unordered Lists, and SharePoint Part 2 – Custom Control Rendering Part 3 – Hooking it all up with jQuery Although the styling and navigation had to be scrubbed, a [...]]]></description>
			<content:encoded><![CDATA[<p>This is part one in a three part series for implementing Mega Drop Down navigation in SharePoint 2007.&#160; The topics covered are:</p>
<p><b>Part 1 – Tables, Unordered Lists, and SharePoint</b>    <br /><a href="http://sharepoint.inproc.com/creating-mega-drop-down-navigation-in-sharepoint-with-jquery-part-2/">Part 2 – Custom Control Rendering</a>    <br />Part 3 – Hooking it all up with jQuery</p>
<p>Although the styling and navigation had to be scrubbed, a screen cast of the final solution can be found <a href="http://www.youtube.com/v/elOZ9-iA4Dc&amp;hl=en" target="_blank">here</a>:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:17aa91e9-d35b-4116-ac3a-64bce728d961" class="wlWriterSmartContent">
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px" id="c4ea29e5-7dd4-4320-aa0d-a7190ec2bbb0">
<div><object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355"><param name="_cx" value="9813"><param name="_cy" value="8197"><param name="FlashVars" value=""><param name="Movie" value="http://www.youtube.com/v/elOZ9-iA4Dc&amp;hl=en"><param name="Src" value="http://www.youtube.com/v/elOZ9-iA4Dc&amp;hl=en"><param name="WMode" value="Window"><param name="Play" value="-1"><param name="Loop" value="-1"><param name="Quality" value="High"><param name="SAlign" value=""><param name="Menu" value="-1"><param name="Base" value=""><param name="AllowScriptAccess" value=""><param name="Scale" value="ShowAll"><param name="DeviceFont" value="0"><param name="EmbedMovie" value="0"><param name="BGColor" value=""><param name="SWRemote" value=""><param name="MovieData" value=""><param name="SeamlessTabbing" value="1"><param name="Profile" value="0"><param name="ProfileAddress" value=""><param name="ProfilePort" value="0"><param name="AllowNetworking" value="all"><param name="AllowFullScreen" value="false"><embed type="application/x-shockwave-flash" width="425" height="355" src="http://www.youtube.com/v/elOZ9-iA4Dc&amp;hl=en">&#160;</embed></object></div>
</p></div>
</p></div>
<p>Providing users with rich navigation is the latest trend in web design and the hottest technique today is the Mega Drop Down.&#160; Rather than providing single column navigation, Mega Drop Downs present menu information in a rich, two-dimensional format:</p>
<p><a title="Mega Drop Down" href="http://tothepoint.inproc.com/wp-content/uploads/2009/08/image.png" rel="lightbox"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://tothepoint.inproc.com/wp-content/uploads/2009/08/image_thumb.png" width="644" height="189" /></a></p>
<p>As you can see in the above example, the drop down menu provides navigation links in multiple columns (and even has a slick transparency effect).&#160; Sites with Mega Drop Downs are popping up all <a href="http://www.chicagobears.com" target="_blank">over</a> <a href="http://www.foodnetwork.com" target="_blank">the</a> <a href="http://www.whitehouse.gov/" target="_blank">web</a> and usability guru Jakob Nielsen has written a great <a href="http://www.useit.com/alertbox/mega-dropdown-menus.html" target="_blank">article</a> describing the benefits.</p>
<p>For most sites, implementing a Mega Drop Down is fairly straightforward and most of the effort focuses around CSS.&#160; If you have ever customized navigation in SharePoint, you are well aware that things are easy enough—but only to a point.</p>
<p>Out-of-the-box, SharePoint uses the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.aspmenu.aspx" target="_blank">SharePoint:AspMenu</a> class that inherits from the standard ASP.NET <a href="http://msdn.microsoft.com/en-us/library/ecs0x9w5%28VS.80%29.aspx" target="_blank">asp:Menu</a> control.&#160; This control provides the ability to be skinned and can be customized through the use of CSS and ItemTemplate support, but at its core, it still is a &lt;TABLE&gt; based control and isn’t flexible enough to radically change its appearance.</p>
<p>Rather than relying on &lt;TABLE&gt; based navigation, CSS unordered lists &lt;UL&gt; can easily be used to implement navigation.&#160; I want to keep this post focused on SharePoint and not CSS, so if you want to read up on how to create the shell for the Mega Drop Down, I recommend starting with this <a href="http://www.sitepoint.com/blogs/2009/03/31/make-a-mega-drop-down-menu-with-jquery/" target="_blank">article</a>,&#160;&#160; To summarize the concepts, we essentially create a nested set of unordered lists:</p>
<p>  <pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 560px; padding-right: 5px; font-family: consolas, &quot;Courier New&quot;, courier, monospace; font-size: 12px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">&amp;lt;ul id=’topNav’&gt;
  &lt;li&gt;Employee Services&lt;/li&gt;
    &lt;div id='mdd'&gt;
      &lt;h3&gt;Benefits&lt;/h3&gt;
       &lt;ul id='subNav'&gt;
        &lt;li&gt;401(k) Information&lt;/li&gt;
      &lt;/ul&gt;
     &lt;/div&gt;
   &lt;/li&gt;
&lt;/ul&gt;</pre></p>
<p>&#160;</p>
<p>The ‘topNav’ &lt;ul&gt; represents the top navigation that is displayed horizontally.&#160; The &lt;div&gt; is the actual Mega Drop Down itself and contains one or more ‘subNav’ &lt;ul&gt; elements that represent the sub-menu items.&#160; The &lt;h3&gt; tag is used as a category heading so we can group menu items together (more on that in part 2). </p>
<p>CSS is used to style the outer ‘topNav’ so elements are displayed inline.&#160; We also hide the &lt;div&gt; as it should only appear when you hover over an &lt;li&gt; within ‘topNav’.&#160; I applied some extra styling, but so far, navigation should look something like this:</p>
<p>&#160;</p>
<p><a title="New Top Navigation" href="http://tothepoint.inproc.com/wp-content/uploads/2009/08/image1.png" rel="lightbox"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://tothepoint.inproc.com/wp-content/uploads/2009/08/image1.png" width="644" height="281" /></a></p>
<p>&#160;</p>
<p>We’ve defined the structure of the menu and navigation, but up until now, it has all been static.&#160; To make this work in SharePoint, we have to provide a method of displaying navigation dynamically.&#160; There are several different methods of replacing the default navigation, and for this solution, I opted to create a custom navigation control.&#160;&#160; A great overview of the various options can be found <a href="http://blogs.msdn.com/modonovan/archive/2008/05/30/custom-navigation-in-sharepoint-the-full-monty.aspx">here</a>.&#160; Earlier I mentioned that out of the box, SharePoint uses the asp:Menu control to render menu items.&#160; This is a standard data-bound control that references a DataSource for rendering navigation.&#160; If you look inside default.master with SharePoint Designer, you’ll see how all this works:</p>
<p>&#160;</p>
<p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 560px; padding-right: 5px; font-family: consolas, &quot;Courier New&quot;, courier, monospace; font-size: 12px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">&lt;SharePoint:AspMenu
  ID=&quot;TopNavigationMenu&quot;
   DataSourceID=&quot;topSiteMap&quot;
   runat=&quot;server&quot;
   ...
/&gt;
&lt;asp:SiteMapDataSource
  ShowStartingNode=&quot;False&quot;
   SiteMapProvider=&quot;SPNavigationProvider&quot;
   id=&quot;topSiteMap&quot;
   runat=&quot;server&quot;
  StartingNodeUrl=&quot;sid:1002&quot; /&gt;</pre></p>
<p>&#160;</p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sitemapdatasource.aspx" target="_blank">SiteMapDataSource</a> is a standard ASP.NET data source control and is widely used in ASP.NET web development.&#160; If you are not familiar with how navigation works in ASP.NET, MSDN has a great <a href="http://msdn.microsoft.com/en-us/library/ms178359.aspx" target="_blank">overview</a>.&#160; The important concept to note here is the SiteMapProvider property and the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.navigation.spnavigationprovider.aspx" target="_blank">SPNavigationProvider</a> value.&#160; SPNavigationProvider is a class that follows the standard <a href="http://msdn.microsoft.com/en-us/library/ms972319.aspx" target="_blank">provider model</a> and essentially is the code that retrieves the navigation hierarchy from SharePoint.&#160; SPNavigationProvider handles all the mundane tasks of retrieving the data and security trimming results so users don’t see links to sites that they may not have access to.</p>
<p>As mentioned, we are scrapping the SharePoint:AspMenu control because it renders &lt;TABLE&gt; based navigation and are replacing it with a shiny, new &lt;UL&gt; based navigation control.&#160; Other than being difficult to pronounce (and type), <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hierarchicaldataboundcontrol.aspx" target="_blank">HierarchicalDataBoundControl</a> is the underlying class that asp:Menu uses to retrieve its data.&#160; We are simply bypassing asp:Menu and its bias for &lt;TABLE&gt; layouts and going directly at the data.&#160;&#160; Our custom control’s declaration looks something like this</p>
<p>:</p>
<p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 560px; padding-right: 5px; font-family: consolas, &quot;Courier New&quot;, courier, monospace; font-size: 12px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">public class MegaDropDown : HierarchicalDataBoundControl
{
   protected override void PerformDataBinding()
   protected override void Render(HtmlTextWriter writer)
}</pre></p>
<p>&#160;</p>
<p>The two methods that we need to override are PerformDataBinding() and Render().</p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.databoundcontrol.performdatabinding.aspx" target="_blank">PerformDataBinding</a> method is where we will retrieve our data from the data source (indirectly through SPNavigationProvider) and then (ultimately) parse the hierarchical data that is returned.&#160; Initially, the GetData() method is called to…wait for it…get the data.&#160; In general, these controls can represent many different flavors of data.&#160; Since we are working with hierarchical data, GetData() happily returns a reference to a <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.hierarchicaldatasourceview.aspx" target="_blank">HierarchicalDataSourceView</a> object that represents a view into the navigation.&#160; A data source view is similar to a database view and has the ability to provide a subset of data based on a query.&#160; Coincidentally, HierarchicalDataSourceView points to a nested list of the navigation data.&#160; For our purpose, there isn’t a need a need to filter results and a simple call to the Select() method will suffice.</p>
<p>Having a reference to the view is great, but what we really want is an enumerable reference to the actual data (remember, the view is just an abstraction of the data).&#160; Having the IHierarchyData interface gives us so many options (well, not really) but since everyone likes enumerable objects, getting to the data is only a two-step process.&#160; Once we call GetHierarchyData(), we only need to invoke IHierarchyData.GetChildren() to access the enumerable data</p>
<p>Surprisingly it is very straightforward and only involves a dozen or so lines of code::</p>
<p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 560px; padding-right: 5px; font-family: consolas, &quot;Courier New&quot;, courier, monospace; font-size: 12px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px">protected override void PerformDataBinding()
{
   base.PerformDataBinding();

   // Do not attempt to bind data if there is no data source set.
   if (!IsBoundUsingDataSourceID &amp;&amp; (DataSource == null))
      return;

   HierarchicalDataSourceView view = GetData(&quot;&quot;);

   if (view == null)
      throw new InvalidOperationException(&quot;Cannot get any data.&quot;);

   IHierarchicalEnumerable enumerable = view.Select();

   if (enumerable != null)
   {
      IHierarchyData data = enumerable.GetHierarchyData(rootItem);
      IHierarchicalEnumerable newEnum = data.GetChildren();
   }
}</pre></p>
<p>
  <br />Next up is the HTML rendering and actual control implementation…<a href="http://sharepoint.inproc.com/creating-mega-drop-down-navigation-in-sharepoint-with-jquery-part-2/">Part 2 – Custom Control Rendering</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsharepoint.inproc.com%2Fcreating-mega-drop-down-navigation-in-sharepoint-2007-with-jquery%2F&amp;title=Creating%20Mega%20Drop%20Down%20Navigation%20in%20SharePoint%20with%20jQuery%20%26%238211%3B%20Part%201" id="wpa2a_10"><img src="http://sharepoint.inproc.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fsharepoint.inproc.com%2Fcreating-mega-drop-down-navigation-in-sharepoint-2007-with-jquery%2F&amp;title=Creating%20Mega%20Drop%20Down%20Navigation%20in%20SharePoint%20with%20jQuery%20%26%238211%3B%20Part%201" id="wpa2a_12"><img src="http://sharepoint.inproc.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://sharepoint.inproc.com/creating-mega-drop-down-navigation-in-sharepoint-2007-with-jquery/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

