- Back to Home »
- Minimize Form Ribbon OnLoad using JavaScript
Hey Guys,
I am currently developing a CRM system in 2011 for one of our biggest clients. One of the requirements is to create editable lists which i have decided is best handled by creating holding entities for this information. For example, creating an entity to hold marketing sources allows easier reporting across selected sources and allows the marketing team to manage the list (adding new ones and deactivating unused ones). The problem with this is that to add a value to this it involves opening a whole CRM form which isn't the best. So, for these entities I don't display the left-navigation options and i wanted to minimize the Ribbon.
However, this wasn't as easy as it sounds…
First of all, having scoured the SDK i could see plenty of examples of how to add or hide BUTTONS on the ribbon and even (via other blogs) remove the ribbon itself, but nothing that would minimize the ribbon allowing it to be expanded if needed.
So after a conversation with the very helpful xRM Mike and reading another post by the excellent Rhett Clinton I used the following:
window.top.document.getElementById("minimizeribbon").fireEvent("onclick");
However, still didn't work…..
Reason being, that the Ribbon seems to be one of the last things to Load in the form, loading after the OnLoad events have fired. So, i needed to add a timeout to wait before firing the script and it worked a treat! Final code ended up as:
function toggleRibbonbar()
{
var t=setTimeout("toggleRibbon()",0);
}
function toggleRibbon()
{
window.top.document.getElementById("minimizeribbon").fireEvent("onclick");
}
Which gave the following results:
A big thanks to Rhett, Mike and as always the other CRM Legend that is Rob P
Ta
xRM Consultant
hey i'm Abhi
ReplyDeleteReally nice blog keep growing man
Yoga For Stress And Depression
yoga for stress anxiety and depression
yoga for stress anxiety depression
yoga poses for stress and depression