Sunday, December 19, 2010

Put a View in a form and on select of that record load the same to the Form in another Iframe

Its very frequent requirement.
like i want to put a view to the forma and on select(double click) it should load also to the same form(another iframe).

So just follow the following steps.
make sure the IFRAME names. change as per yours.

//*********************************************************************************
//put the two iframes and load the record on double cick of the record from one Iframe
//*********************************************************************************

//get the server url with port (if anything else 80) u can not really rely ;)
function getServerUrlWithPort()
{
return window.location.protocol + "//" + window.location.host ;
}

//this is for the
function OnGridViewReady()
{

var gridview = document.all.IFRAME_Grid;
if( gridview.readyState != 'complete' )
return;
gridview.contentWindow.document.getElementById('crmGrid_JumpBar').parentNode.parentNode.style.display = 'none';
gridview.contentWindow.document.getElementById("quickFindContainer").parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display = "none";

gridview.contentWindow.document.getElementById("crmMenuBar").parentNode.parentNode.style.display = 'none';

var gridviewDocument = gridview.document.frames["IFRAME_Grid"].document;
var gridviewWindow = gridviewDocument.parentWindow;
gridviewWindow.open = OnWindowOpen;
gridviewDocument.body.scroll = "no";
}

//this will bind the url to the 2nd IFrame instead of opening it as new window
function OnWindowOpen( url )
{
var formview = document.all.IFRAME_Form;
//alert("aaaa"+url+"#######"+formview );
formview.src = getServerUrlWithPort() + url;

if (url != "/" + this.parent.ORG_UNIQUE_NAME + "/sfa/accts/edit.aspx")
return false;
}

//this will be fired when the form will be loaded to the 2nd IFrame
//hide the left nav area and other menu items also
function OnFormViewReady()
{
var formview = document.all.IFRAME_Form;

if( formview.readyState != 'complete' )
return;

formview.document.frames['IFRAME_Form'].document.body.style.border = "1px solid #6893cf";

if (formview.contentWindow.document.getElementById('leftNavBreadcrumbImg') == null)
return;
formview.contentWindow.document.getElementById('leftNavBreadcrumbImg').parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none';
formview.contentWindow.document.getElementById('leftNavBreadcrumbImg').parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.height = '45';

formview.contentWindow.document.getElementById('crmMenuBar').parentNode.parentNode.style.display = 'none';
formview.contentWindow.document.getElementById('crmNavBar').parentNode.style.display = 'none';
formview.contentWindow.document.getElementById('tdAreas').colSpan = 2;
formview.contentWindow.document.getElementById('crmRenderStatus').parentNode.parentNode.style.display = 'none';
formview.contentWindow.document.getElementById('help').parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none';

}

var Grid = crmForm.all.IFRAME_Grid;
var Form = crmForm.all.IFRAME_Form;
Grid.attachEvent("onreadystatechange",OnGridViewReady);
Form.attachEvent("onreadystatechange",OnFormViewReady);


//hide tab
crmForm.all.tab1Tab.style.display="none";

document.getElementById('help').style.display = "none";
document.getElementById('mnuDown').style.display = "none";
if(document.getElementById('navAsyncOperations') !=null)
{
document.getElementById('navAsyncOperations').style.display="none";
}

Sudhanshu

No comments:

Post a Comment