Skip to content

The Chris Kent

Quick Fixes, Workarounds, and Other Neat Tricks

  • Home
  • About
  • Speaking
HomePosts tagged 'Tree'

Tree

Changing the Width of the Left Panel

May 11, 2012May 9, 2012 theChrisKent Branding, List/Library Settings, SharePoint CSS, Left Panel, Master Page, MetaData Navigation, MSO_ContentTable, s4-leftpanel, SharePoint, Tree
Applies To: SharePoint 2010

We’ve been using the MetaData Navigation on a site with custom branding and everything’s been working great. Recently, they decided to remove the Key Filters. This was simple enough using the List Settings but I quickly found that the width of the Left Panel automatically cut off my taxonomy item names without the Key Filters there to stretch it.

Users can easily grab the little bar and grow this part of the left panel’s treeview, but why should they have too for initial viewing? Some quick digging in the rendered HTML showed that the Left Panel’s width was set to 155 px by default. All I wanted was to change that to 200 px.

So, I opened my custom master page (based on v4.master) and went to the div with id=”s4-leftpanel” and found that the style was not set there and was being set in code somewhere. No worries, if you do set it here, it won’t be overridden by whatever part of the code assigns these values. So to adjust your default width just add a style attribute to your s4-leftpanel div:

<div id="s4-leftpanel" style="width:200px;">

If you save this and check it on a live site you’ll find things don’t look right. The key is to also adjust the  MSO_ContentTable div to have a matching left margin:

<div id="MSO_ContentTable" style="margin-left:200px;">

Voila! That’s it! The width can still be adjusted by the end user using the grab bar, but the default is set and you are happy.

Rate this:

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • Tumblr
  • Pinterest
  • Reddit
  • LinkedIn

Like this:

Like Loading...
3 Comments

Changing the Default Expansion of MetaData Navigation on Initial Page Load

May 9, 2012 theChrisKent .NET, Information Management, List/Library Settings, MetaDataNavExpansion, SharePoint .NET, Managed Metadata, MetaData Navigation, MetaDataNavTree, SharePoint, Taxonomy, Timer Job, Tree, WireBear
Applies To: SharePoint 2010

We’ve recently begun making fairly heavy use of the MetaData Navigation available for lists. It’s intuitive and easy to use and our users are really liking it. But one minor, but frequently mentioned, irritation brought up by nearly everyone who tried to use the site was that the navigation elements were collapsed by default when they went to the site.

This isn’t a big deal for most people since they get used to where the navigation elements are (just expand the folder), but does create an extra barrier for new users as they try and figure out how to use the site. Microsoft has taken an awesome feature and traded it’s potentially intuitive use to account for some potential performance issues.

The issue seems to be that navigation using taxonomies with several top level items would significantly delay initial page load. This is certainly true, but the solution is not to cripple all uses of MetaData Navigation, the solution is to not use it with those types of taxonomies! Not only would you have had that performance issue on initial expansion anyway, having that many top level items makes for bad navigation. If your taxonomy has several top level items (2000+) then it is either not a good candidate for MetaData navigation or you need to group those items into sub-nodes.

In searching for an answer to this problem I came across this answer on technet by Entan Ming. In it he gives the manual steps to take care of this issue. Here is a brief summary of the steps that must be performed manually on every server:

  1. Open the MetadataNavTree.ascx file in your 14 Hive (TEMPLATE\CONTROLTEMPLATES) using notepad
  2. Change the line ExpandDepth=”0″ to ExpandDepth=”2″
  3. Save the changes and refresh the page(s) with MetaData Navigation

These are easy to do and you can follow them and be done. However, just like PDF Icon Mapping there are some problems with this approach:

  • Manual changes can often be error-prone
  • The change must be performed on every server
  • The change must be performed whenever a new server is added to the farm
  • The change will have to be redone in the event of disaster recovery

So, using the same technique I use for PDF Icon Mapping entries, I’ve created a SharePoint solution to do this automatically.

You can find this solution over on CodePlex as WireBear MetaDataNavExpansion. It is free for personal and commercial use (License here). You can also find basic installation instructions as well. It’s super easy to setup since it’s just a standard SharePoint Solution that you globally deploy.

The full source code is available on CodePlex and I’ll write up another article about what’s really happening, but here’s a general summary:

  • On Activation and Deactivation a one time Service Timer Job is run.
  • On Activation, the Timer Job creates a backup of the MetaDataNavTree.ascx file within the 14\TEMPLATE\CONTROLTEMPLATES folder.
  • The MetaDataNavTree has it’s tree’s ExpandDepth property changed from 0 to 2
  • When Deactivating, the Timer Job restores the original MetaDataNavTree.ascx file

It’s pretty straightforward. It just automates the manual steps listed above. This allows it to be applied automatically to any new servers added to the farm and will be reapplied in the event of disaster recovery.

Here’s what it looks like on initial page load

Standard: With MetaDataNavExpansion:
   
“Der… What do I do?” “WOWEE! This site is amazing!”

Rate this:

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • Tumblr
  • Pinterest
  • Reddit
  • LinkedIn

Like this:

Like Loading...
3 Comments

Office Development

Recent Posts

  • Thank you Microsoft 365 Conference!
  • Getting the Binary Value of an ASCII Character in Power Apps
  • Converting Integers to Binary in Power Apps
  • Converting Binary to Integers in Power Apps
  • Thank you M365 Collaboration Conference!

Popular Posts

  • Applying Column Formats to Multi-line Text Fields
  • Custom Icon Buttons in Power Apps with Hover Color
  • Generate List Formatting Elements in a Loop Using forEach
  • Formatting Values Using "Contains" in List Formatting
  • Validate Email Address Columns in SharePoint

Archives

  • December 2022
  • May 2022
  • April 2022
  • May 2021
  • June 2020
  • April 2020
  • November 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • August 2018
  • July 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • August 2015
  • April 2015
  • February 2015
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • August 2013
  • March 2013
  • February 2013
  • January 2013
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
Create a website or blog at WordPress.com
  • LinkedIn
  • Twitter
  • Follow Following
    • The Chris Kent
    • Join 367 other followers
    • Already have a WordPress.com account? Log in now.
    • The Chris Kent
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...
 

    %d bloggers like this: