为CRM网格着色 [英] Colorize the CRM grid

查看:82
本文介绍了为CRM网格着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Dynamics CRM 4上为CRM网格着色?

How can I colorize the CRM grid on Dynamics CRM 4?

我想在加载视图时自动以反色显示实体列表。

I would like to automatically display the list of an entity with a back color when loading the view.

我的目标是根据所列出实体的状态使用不同的颜色。例如,我想为具有过去日期字段的案件提供一种颜色,为将来有该日期的案件提供另一种颜色。

My goal is to have different colors depending on the status of the listed entity. For example, I want to have a color for cases that have a date field that is in the past and another color for cases that have this date in the future.

推荐答案

下面描述的解决方案是Microsoft 不支持的更改(也就是说,使用此方法需您自担风险)。另外,不能保证应用CRM汇总时不会损坏它。

The solution described below is a change not supported by Microsoft (that means, use it at your own risks). Plus, there is no guarantee that it won't be broken when applying CRM rollups.

在CRM服务器上,修改 C:\Program Files\Microsoft Dynamics CRM\CRMWeb\_static\_grid\grid.htc 文件:

On the CRM server, modify the C:\Program Files\Microsoft Dynamics CRM\CRMWeb\_static\_grid\grid.htc file:

initializeData()函数的末尾添加以下代码:

Add the following code at the end of the initializeData() function:

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";
            }
        }
   }
}

这就是您得到的:

这篇关于为CRM网格着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆