1

I have got the idea from this, To colorize the gridview but he go for the on premises account. So please let me know is there any way to do the above the job on sitting online account or trial version.

Community
  • 1
  • 1
user2951753
  • 103
  • 1
  • 3
  • 13

3 Answers3

1

I found a better solution for this: https://crmgridplus.codeplex.com

PhuocLe
  • 131
  • 1
  • 5
0

You can definitely do that using javascript but manipulating DOM isn't supported by microsoft

Ps: can be done on both online and onpremis

minohimself
  • 496
  • 3
  • 9
0

Found this on the web. Looks short and simple but also Seems horribly inefficient I bet the user feels the pain if the grid contains 250 records per page.

function alterGridRecords() {
    var gridTH = document.getElementById("crmGrid_divDataArea");
    var headers = gridTH.getElementsByTagName("TH");
    var tdata = gridTH.getElementsByTagName("TD");
    for (var n = 0; n < headers.length; n++)  {
        if (headers[n].innerText == "Rating") {
            for (var i = 0; i < tdata.length; i++)  {
                if (tdata[i].innerText == "Hot") 
                    tdata[i].style.backgroundColor = "green";
            }
        }
    }
}

So I rewrote it on the fly (not tested) to make it more efficient.

function alterGridRecords() {
   var colName = "Rating";
   var gridId  = "crmgrid id here";
   var gridTH = document.getElementById(gridId);

   //find colName index
   var colIndex = (function(){ 
       var aTH = gridTH.getElementsByTagName("TH");
       for(var i = 0 ; i < aTH.length ; i++)
           if (aTH[i] == colName) return i;
       return -1;
   })();

   if (colIndex == -1) return;

   var colors = {
      Hot : "red",
      Cold : "green"
   }

   var rows = gridTH.getElementsByTagName("TR");    
   for (var r = 0 ; r < rows.length ; r++)
   {
       var cell = rows[r].cells[colIndex];
       cell.style.backgroundColor = colors[cell.innerText];
   }
}

Note: You also need to bind to the grid events to get the records repainted every time the user pages , does a quick search or refreshed the data

Adi Katz
  • 548
  • 3
  • 9