2

I use the following solution on CRM 4 in order to colorize the CRM grid, depending on the values of several fields. It works fine, except the rows are not highlighted with a different color anymore when they are selected.

This is the usual interface:

Usual interface

This is my interface:

My interface

Is there anyway to get back the highlight color? And to change it?

Community
  • 1
  • 1
Otiel
  • 18,404
  • 16
  • 78
  • 126
  • what caused it to stop working? – Greg Owens Jun 20 '12 at 20:42
  • @Greg It stopped working as soon as I added the code in the grid.htc file (see http://stackoverflow.com/a/10813205/825024) – Otiel Jun 22 '12 at 07:03
  • Sorry Otiel this fell off my radar - got very busy just after starting to answer this. If you enable script debugging in IE (Press F12 > Script > Start Debugging) then you try to select a row, do you see any errors? – Greg Owens Jul 23 '12 at 14:19

1 Answers1

0

Thinking about this a bit more, the issue here I suspect is that you are blanket changing the row colour when you initialise the grid. From the [linked] code:

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

My first thought is to colourise only some of the columns in the row. Row highlighting would then apply to the rest of the row. This is just a quick lash-together. Further, it is untested.

You will get the idea and maybe write this to better to suit your requirements

E.g:

var colour1 = "ff0066";
var colour2 = "ff6600";

if (new_date_value <= current_datetime) {
    colouriseRow(InnerGrid.rows[i], colour1);
} else {
    colouriseRow(InnerGrid.rows[i], colour2);
}

function colouriseRow(myRow, cols){
    for(var i = 0; i < myRow.cells.length; i++){
        if(i > 2){ // skip the first 3 columns, colourise the rest
            myRow.cells[i].style.backgroundColor=myColour;
        }
    }
}
Greg Owens
  • 3,878
  • 1
  • 18
  • 42
  • Hm, I can't get it to work, I'm not sure why. But anyway, it's not what I would like to do as I want to keep the whole row colorized. Thank you though. – Otiel Jul 27 '12 at 14:18