El del CRM

The adventures of a Dynamics CRM geek

El del CRM

Hiding the left navigation panel on a CRM entity

Tuesday, August 04 2009 by admin - Blog - 1 Comment

This one started as a weird requirement, although it was totally justified from the clients perspective. In one of our customers deployment there was a very simple entity that didn’t require to show the left hand side navigation panel and for User Experience’s sake it was decided that this navigation panel should go.

Obviously there is no supported way of doing this, however, we are dealing as usual with HTML and JavaScript and you can always do some unsupported manipulations. Moreover, Microsoft Dynamics CRM application uses a similar trick when presenting an entity’s form in some special occasions like the workflows and form designer.

So, with some bits of JavaScript on the on-load event we can manage to change the display of the navigation items to none, and modify the main form area to automatically expand to cover the space left. Here is the code for the onload.

 

function getElementsByClassName(classname, node)  {
if(!node) node = document.getElementsByTagName("body")[0];
var a = [];
var re = new RegExp('\\b' + classname + '\\b');
var els = node.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++)
if(re.test(els[i].className))a.push(els[i]);
return a;
}

var elements = getElementsByClassName('ms-crm-Form-LeftBar');

for (var p=0; p<elements.length; p++)
{
elements[p].style.display = 'none';
elements[p].style.width = '1%';
}

var tables = getElementsByClassName('ms-crm-Form-Layout');

for (var k=0; k<tables.length; k++)
{
tables[k].style.tableLayout = 'auto';
}

 

And here is a screen capture of how it looks like before and after.

Before

 image

After – Without left hand navigation panel

image

 

Hope it helps.

Marco Amoedo

Tagged as: ,

Trackback URL to this Post http://marcoamoedo.com/trackback.ashx?id=32

1 Comment

  • #1 Rob Burke

    Awesome little trick dude - these are some of those unsupported hacks you mentioned @ Epicenter eh? ;-)

    Have you ever hooked jQuery into CRM?

Sorry comments are closed for this post

There are no trackbacks .