2014-03-30 48 views
0

不加載網格要在I幀加載形式的網格,在窗體加載事件中,我加入這個這個腳本:自定義高級查找在2011年CRM視圖中的iFrame在Firefox和IE

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); 

} 

它在Chrome中正常工作,但在IE和Firefox中,它只顯示「加載視圖...」。我檢查了所有三個瀏覽器中的網絡請求,並發現在Chrome中有一個「fetchData.aspx」的發佈請求,但在Firefox或IE中沒有這樣的請求。

回答

1

剛剛找到了解決方案。

而不是創建使用使用document.createElement和形式......我創建的字符串形式,放入iframe的innerHTML的,它的工作

http://social.microsoft.com/Forums/en-US/f375d23c-8867-4296-9775-3df995420579/custom-advance-find-view-in-iframe-in-crm-2011-does-not-load-gird-in-firefox-and-ie

+0

嗨,我有同樣的問題。我嘗試了你的靈魂,但沒有運氣。 你可以提供你更新的代碼片段/解決方案。 –

+1

嗨。請閱讀上面提到的鏈接中的最後一個回覆。你可以找到我使用的代碼。 –

相關問題