My Battle with the Quick Launch Accordion Slider Control

A good portion of this week was spent recovering some documents that were deleted by a rogue console application (most likely my fault).  I wrote a Console Application to combine some document libraries and I spent a good portion of a week testing it.  However, I did not really think of enough scenarios, because it obviously did not move the documents properly.  Some libraries were moved and others were not.  At any rate I practiced my SQL Restoration skills and wrote another two console applications to print out the document count for the libraries on our current portal and the restored portal.  Then I compared the lists and copied over the missing files.  The rest of the week was spent on this quick launch modification issue.  I am not a JavaScript Guru, but I am stubborn person who will tackle Google and my own brain for a few days before giving up.

It was a pretty long day and I was pretty frustrated, so I went to our JavaScript Guru at work, Kevin.  He's a really cool guy and knows some pretty neat things about JavaScript and AJAX.  I told him we wanted to use the SharePoint Quick Launch Menu Control (SharePoint:ASPMenu) with an expand/collapse accordion/slider control type menu.  I had tried a few different menu options and realized that most of them would not work, because SharePoint will override the CSS.  The easiest way to do anything is to stick with there controls and bend the rules a little.  About 6/7 pm on Friday I check my Gmail account and Kevin sent me an e-mail with some code.  One hour later after some dinner and a movie I crack open my web user control and test it out.  Sure enough it works.  Here is a reference to the link that he used:

Here is the code that finally ended up at the top of the user control:

If you paste that into the header of your page and add the ID of the menu above, then it should expand/collapse your headers and hide/un-hide your child nodes.  In future I will show you guys how to loop through and add Quick Launch Nodes and any additional nodes you would like to the Quick Launch Menu Control.  This is just a neat little tidbit that you guys can play with for now.  Remember: JavaScript is fun, but if you can use a.Net Control or Code it is more manageable in the long run.  Have a good weekend guys!

This article is part of the GWB Archives. Original Author: MOSSLover

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.