简体   繁体   中英

Colorise the gridview in dynamics crm 2013?

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.

我为此找到了更好的解决方案: https : //crmgridplus.codeplex.com

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

Ps: can be done on both online and onpremis

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM