Thursday, November 08, 2012

WebpartToolPart category "Appearance" expanded by default - How to revert this ?

I had this problem myself the other day and it seems that all the solutions I found where mostly javascript based. But this is not a good solution in my mind, therefore I did some reflection and came up with this solution, all server side.

public override ToolPart[] GetToolParts()
{

var list = new List<ToolPart>(base.GetToolParts());

foreach (var wptp in list.OfType<WebPartToolPart>())
{
HideExpandIndexes(wptp);
}

return list.ToArray();
}


private void HideExpandIndexes(WebPartToolPart part)
{

var field_helper = part.GetType().GetField("_helper", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
var _helper = field_helper.GetValue(part);

var field_expandIndexes = _helper.GetType().BaseType.GetField("_expandIndexes", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
var _expandIndexes = field_expandIndexes.GetValue(_helper);

var field_items = _expandIndexes.GetType().GetField("_items", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
var _items = (Hashtable)field_items.GetValue(_expandIndexes);

_items.Clear();
}





The code can be improved to a finer detail, but it solves the problem for the moment.

Tuesday, November 06, 2012

SharePoint Manager 2013 (ver: 1.0.12.1106) released

SharePoint Manager 2013 (ver: 1.0.12.1106) is now out of beta and official released for SharePoint 2013 RTM. http://spm.codeplex.com/releases/view/97332

The new version has an expanded view of the SharePoint object model and has been tested on SharePoint 2013 RTM.

As a bonus, the new SharePoint Manager 2013 (ver: 1.0.12.1106) is also available for SharePoint 2010 as a separate download.