2012-05-30 38 views
2

如何在Dynamics CRM 4上着色CRM網格?着色CRM網格

我想在加載視圖時自動顯示帶有背景顏色的實體列表。

我的目標是根據所列實體的狀態有不同的顏色。例如,我希望爲過去具有日期字段的案例和未來具有此日期的案例使用另一種顏色。

回答

2

下面介紹的解決方案是Microsoft不支持的更改(也就是說,在您自擔風險時使用它)。此外,不能保證在應用CRM彙總時它不會被破壞。


在CRM服務器,修改文件:

添加以下代碼在initializeData()函數的末尾:

if (window.location.href.toLowerCase() == 
    "http://CrmServerName:5555/OrganizationName/cs/home_cases.aspx") { 
    // We ensure that we are on the organization we want to colorize and that we 
    // are on the Cases page 

    var colorizeColumn = InnerGrid.FindColumnIndex("new_date"); 

    if (colorizeColumn > 0) { 
     // We ensure that the column we'll use to colorize is present 

     for (var i = 0; i < InnerGrid.AllRecords.length; i++) { 
      // For each line 

      // Build the date value from the displayed date 
      var new_date_displayed = InnerGrid.AllRecords[i][3]. 
       cells[colorizeColumn].innerText; 
      var new_date_value = new Date(new_date_displayed.substring(6,10), 
              new_date_displayed.substring(3,5) - 1, 
              new_date_displayed.substring(0,2), 
              new_date_displayed.substring(11,13), 
              new_date_displayed.substring(14,16), 0, 0); 
      // Get current date 
      var current_datetime = new Date(); 

      if (new_date_value <= current_datetime) { 
       InnerGrid.rows[i].style.backgroundColor="ff0066"; 
      } else { 
       InnerGrid.rows[i].style.backgroundColor="ff6600"; 
      } 
     } 
    } 
} 

這裏就是你:

Colorized grid

+2

記住,當然這是一個不支持的變化;) –

+0

@Greg:是的,我編輯了我的答案,指出它清楚。謝謝。 – Otiel

+0

這是2011年的工作嗎? – cja