Tuesday, June 7, 2011

how to do alternate colors of records in the grid in ms crm 2011

Sometimes the requirement used to come as the records in the main grid to be alternate colors as in normal grid controls.
keep it in mind we are going to alter the aspx page provided by MS CRM :P
To achieve it in CRM just needs some JS code.

1. open the HomePage.aspx from the _root folder
2. append a method onload of the body as <body class="stage" onload="alterGridRecords()">
3. now the function alterGridRecords should be as followed

function alterGridRecords(){
var grid = document.getElementById("gridBodyTable").lastChild; //gridBodyTable is the id, wch will help
for (var i = 0; i < grid.childNodes.length; i++)
{
if ((i % 2) == 0) {
grid.childNodes[i].style.backgroundColor = "#EEEEEE"; //put color as per the user requested
grid.childNodes[i].colourised = true;
}
else {
grid.childNodes[i].style.backgroundColor = "#FFFFFF"; //put color as per the user requested
grid.childNodes[i].colourised = true;
}
}
}

this is so simple

there is simple prob, as if u will select the records the colors will not be changed to the selected color.
So make the alternate colors to the 1st column only as it it colored only one color in ms crm 2011.
grid.childNodes[i].childNodes[2].style.backgroundColor = "#FFFFFF";

thats it. even if the 1st column will not be colored when selected, other columns will be colored where as the 1st column can make the altered colors :P

have fun. ;)

1 comment:

  1. Customer Relationship Management (CRM) Software is a large class of software programs essentially designed to help businesses manage their customer information. Before making a commitment like this, every business should ask if they require a full CRM Software program.

    ReplyDelete