CRM Home Grid StyleSet

用户进行到记录列表后,虽然可以通过视图来区分不同条件的记录但是不能重点突出记录的重要性。我们根据客户的需求特别定制了如下解决方案,比如根据记录的状态,字段值 在列表面上把行的背景显示成不同的着色来突出重点,提高客户的生产力。
此解决方案可以灵活配置可以放到任意记录上,并且可以设置显示条件

代码如下:


//定义显示条件 var condition={"attribute":"电子邮件","values":[{"value":"hellohongfu@hotmail","style":"background:blue;color:white"},{"value":"362335821@qq.com","style":"background:red;color:white"}, {"value":"hongfu.wang@avanade.com","style":"background:yellow;color:black"}]} //返回不同值的样式 function GetStyle(value){ for(var item in condition.values){  if(value==condition.values[item].value){   console.log(condition.values[item].value + condition.values[item].style)     return condition.values[item].style;   } } } //表格设置 function setTable(table,condition){   var rows =table.rows;   var ths=rows[0];      var columnIndex=0;   $(table).find("tr th").each(function(index,e){     if(condition.attribute==$(this).text()){       console.log($(this).text()+" "+"index:"+index);       columnIndex=index;     }        })   $(table).find("tr").each(function(index,e){     if(index>0){        $(this).find("td").each(function(index,e){          if(index==columnIndex){           if(GetStyle($(this).text())){             console.log('GetStyle')             $(this).parent()[0].style=GetStyle($(this).text());                      }         }       })     }   }); } //查找表格 var table =$($("iframe")[0].contentWindow.document).find("#gridBodyTable")[0] //运行样式 setTable(table,condition);

 最终效果如下图

原文地址:https://www.cnblogs.com/hellohongfu/p/4790768.html