Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Custom Advance Find view in Iframe in CRM 2011 does not load gird in Firefox AND IE

$
0
0

Hi

I added a Iframe to my form and in form load event, I load this script :

var gContext;

function loadIFrame(context) {

	gContext=context.getContext();
    window.fetchActivtities = new FetchViewer("IFRAME_casebysedrialno");
    fetchActivtities.FetchXml = getFetchXml(null,null);
    fetchActivtities.LayoutXml = getLayoutXml();
    fetchActivtities.Entity = "incident";
    fetchActivtities.QueryId = "{B34A5382-F6B7-E311-B5B1-000C2964D6D6}"; // view GUID
    fetchActivtities.RegisterOnTab(2); //IFRAME TAB INDEX


}



function getFetchXml(itemtoSelect,itemValue) {

 //  FetchXML Query
    return '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">'+
				  '<entity name="incident">'+
					'<attribute name="title" />'+
					'<attribute name="ticketnumber" />'+
					'<attribute name="createdon" />'+
					'<attribute name="incidentid" />'+
					'<order attribute="title" descending="false" />'+
				  '</entity>'+
				'</fetch>';

}

function getLayoutXml() {

 // grid layout, you can get easily from Customization.xml file
    return '<grid name="resultset" object="112" jump="title" select="1" preview="1" icon="1">'+
			  '<row name="result" id="incidentid">'+
				'<cell name="title" width="150" />'+
				'<cell name="incidentstagecode" width="100" />'+
				'<cell name="casetypecode" width="100" />'+
				'<cell name="prioritycode" width="100" />'+
				'<cell name="productserialnumber" width="100" />'+
				'<cell name="severitycode" width="100" />'+
				'<cell name="statecode" width="100" />'+
			  '</row>'+
			'</grid>';

}

function FetchViewer(iframeId) {
    var Instance = this;
    var vDynamicForm;
    var m_iframeTab;
    var m_iframeDoc;

    Instance.Entity = "";
    Instance.Iframe = null;
    Instance.FetchXml = "";
    Instance.QueryId = "";
    Instance.LayoutXml = "";

    Instance.RegisterOnTab = function (tabIndex) {
        Instance.Iframe = document.getElementById(iframeId);

		
		
        if (!Instance.Iframe)
            return alert("Iframe " + iframeId + " is undefined");

        m_iframeDoc = getIframeDocument();
        var loadingGifHTML = "<table height='100%' width='100%' style='cursor:wait'>";
        loadingGifHTML += "<tr>";
        loadingGifHTML += "<td valign='middle' align='center'>";
        loadingGifHTML += "<img alt='' src='/_imgs/AdvFind/progress.gif'/>";
        loadingGifHTML += "<div/><b>Loading View...</b>";
        loadingGifHTML += "</td></tr></table>";
        m_iframeDoc.body.innerHTML = loadingGifHTML;

        Instance.Refresh();

    }

    function RefreshOnReadyStateChange() {

        if (Instance.Iframe.readyState != 'complete')
		{
				
				return;
		}
		
		
            

        Instance.Refresh();
    }

    Instance.Refresh = function () {
    
        if (!Instance.Iframe)
		{
		   
            return alert("Iframe " + iframeId + " is undefined");
			}

        m_iframeDoc = getIframeDocument();
		
		

        Instance.Iframe.removeEventListener("onreadystatechange", RefreshOnReadyStateChange);
        vDynamicForm = m_iframeDoc.createElement("FORM");
		vDynamicForm.setAttribute("name","vDynamicForm");
		vDynamicForm.setAttribute("method","post");
		createTwoAttElem(m_iframeDoc,vDynamicForm,"INPUT","type","hidden","name","FetchXml");
		createTwoAttElem(m_iframeDoc,vDynamicForm,"INPUT","type","hidden","name","LayoutXml");
		createTwoAttElem(m_iframeDoc,vDynamicForm,"INPUT","type","hidden","name","EntityName");
		createTwoAttElem(m_iframeDoc,vDynamicForm,"INPUT","type","hidden","name","DefaultAdvFindViewId");
		createTwoAttElem(m_iframeDoc,vDynamicForm,"INPUT","type","hidden","name","ViewType");
        vDynamicForm.action = gContext.getServerUrl()+("/AdvancedFind/fetchData.aspx");
        vDynamicForm.FetchXml.value = Instance.FetchXml;
        vDynamicForm.LayoutXml.value = Instance.LayoutXml;
        vDynamicForm.EntityName.value = Instance.Entity;
        vDynamicForm.DefaultAdvFindViewId.value = Instance.QueryId;
        vDynamicForm.ViewType.value = 1039;
        vDynamicForm.submit();

         
        //Instance.Iframe.attachEvent("onreadystatechange", OnViewReady);
		Instance.Iframe.addEventListener("onreadystatechange", OnViewReady);
    }

    function OnViewReady() {
	
	      
        if (Instance.Iframe.readyState != 'complete') return;

        Instance.Iframe.style.border = 0;
        Instance.Iframe.removeEventListener("onreadystatechange", OnViewReady);
        m_iframeDoc = getIframeDocument();
        m_iframeDoc.body.scroll = "no";
        m_iframeDoc.body.style.padding = "0px";
    }

    function getIframeDocument() {
		myFrame = Instance.Iframe;

        myWindow = myFrame.contentWindow;

        myDoc = myWindow.document;
        return myDoc;
    }

}

function createTwoAttElem(doc,eletoAppend,elemname,att1,att1val,att2,att2val)
{

	var newelem = doc.createElement(elemname);
	newelem.setAttribute(att1,att1val);
	newelem.setAttribute(att2,att2val);
	
	eletoAppend.appendChild(newelem);

}

it works prefectly in Chrome but in IE and Firefox, it only shows "Loading View ...". I inspected network requestes in all three browsers, and saw that in Chrome there is a post request to "fetchData.aspx" but there is not such request in firefox or IE.

P.S: I already read this question


Viewing all articles
Browse latest Browse all 8223

Trending Articles