Dynamics CRM2011 display custom buttons and hidden ribbon in scripted by JS

  First, this method can not be written in the onload of the page, because when returning from the conventional form of a grid sub-region when the ribbon is reloaded and iframe areas where conventional forms will not be refreshed, so if in the words written in the onload controls not so completely the way I take is to use the button Enables Rules in CustomRule (a rule that calls a function within a JScript library) so that each call can be loaded into.

      Here to talk about the code, first obtain the ID custom buttons to be controlled by F12, for example, "new_areacost | NoRelationship | Form | AreaGroupAreaGroup.Mscrm.Form.new_areacost.MainTab.area.submit-Large" really a bit long ah, and the rest very simple

var WinbuttonID="new_areacost|NoRelationship|Form|AreaGroupAreaGroup.Mscrm.Form.new_areacost.MainTab.area.submit-Large";
var WinBtn = window.top.document.getElementById(WinbuttonID);
WinBtn.style.display='';
WinBtn.style.display='none';

This method has been under thank Dan prompt students said that in his prompt decision to abandon a second approach after two days of efforts are lower than the effect.  

      The second is a bit cumbersome and sometimes easy and sometimes not easy to use, why it sometimes easy and sometimes not easy to use it as a system prior to use but succeeded in this system but to die. The reason why it does not work well because parentwindow.document.getElementById (ribbonid) to crawl out of the ribbon is always empty, I do not know why.

var button=Xrm.Page.ui.controls.get("new_name")._control._element.ownerDocument;
var parentwindow=GetFormWindows(button);
var display=true;
if(parentwindow!=null) 
{ 
    var ribbon=parentwindow.document.getElementById(ribbonid); 
    if(ribbon!=null&&display) 
    {
		ribbon.style.display='none';
    }
     else if(ribbon!=null)
    {           
		 ribbon.style.dispaly='';     
    }
 }

function GetFormWindows(cus_document)
{
     return cus_document.defaultView || cus_document.parentWindow; 
}

  

Reproduced in: https: //www.cnblogs.com/VicTang/p/3808997.html

Guess you like

Origin blog.csdn.net/weixin_33963189/article/details/93808967