2012-01-02 106 views
1

如何摺疊/展開表單中的導航項目?有一個函數setDisplayState,但它是用於製表符而不是導航項目。CRM 2011導航項目

如何將導航項目摺疊/展開使用javascript for crm 2011?

+0

問題已解決。您可以在窗體的onload上添加以下函數: function hideNavigation() { \t var nodeList = document.getElementById('crmFormNavSubareas')。childNodes; \t爲(VAR I = 0;我 user1126110 2012-01-02 13:14:47

回答

3

Xrm對象允許interacting with navigation items,但不與導航標籤本身,所以你必須使用不支持的方法(可能/可能不完全破碎或Dynamics CRM中的下一個版本以其他方式無關)。

下面是一個例子,它檢查每個導航選項卡的摺疊狀態並適當摺疊它們。

function SetCollapsedState(navigationName, makeCollapsed) { 
    var navItems = document.getElementById("crmFormNavSubareas"); 
    for (i = 0; i < navItems.childNodes.length; i++) { 
     var navItem = navItems.childNodes.item(i); 
     var navChild = navItem.firstChild.firstChild; 
     var navName = navChild.attributes.getNamedItem("alt").nodeValue; 
     if (navName.indexOf(navigationName) === 0) { 

      // The "alt" property changes to read "Collapsed" or "Expanded" when 
      // the navigation tab is clicked; this is how I imagine the internal 
      // CRM js checks the collapsed state of each tab. 

      if ((makeCollapsed === true && navName.indexOf("Expanded") > 0) 
       || (makeCollapsed === false && navName.indexOf("Collapsed") > 0)) { 
       navItem.firstChild.click(); 
      } 
     } 
    } 
} 

P.S.你的回答作爲對你問題的評論(順便說一句,應該可以作爲實際答案)包含在你的問題中,但是我決定發佈一個更全面的函數,以及提及什麼是Xrm對象句柄/不處理。

+0

+1作爲答案,也是P.S. – glosrob 2012-01-03 00:42:23