EasyUI 中GridView 满足某条件 改变行的背景色

时间:2021-05-08 14:48:18

<table id='grid' class='easyui-datagrid' style='width:1500px;height:450px' url='Ajax-index.php?module=<{$module_name}>&action=Ajax_GridView_Select_Dispose&assigned_user_id=<{$assigned_user_id}>&start_time=<{$start_date}>&stop_time=<{$stop_date}>'
title='投诉列表' iconCls='icon-table' pagination='true' rownumbers='true' fitColumns='true' singleSelect='true' toolbar='#toolbar'
data-options="rowStyler: function(index,row){ return RowStyle(index,row); }" >
<thead>

重点:data-options="rowStyler: function(index,row){ return RowStyle(index,row); }" 

<script type='text/javascript'>
function RowStyle(index,row){
  //alert(row.send_date);//undefined  //取行中的列值
  if(row.send_date!=undefined){
    var date_now=GetDateTime();//alert(date_now);//取当前时间
    date_diff=GetDateDiff(row.send_date, date_now, "day");//alert(date_diff);//时间差
    //var date_diff=GetDateDiff("2010-02-26 16:00:00", "2011-07-02 21:48:40", "day");alert(date_diff);//时间差
    if(date_diff>2){//超过2天时 红色背景色
      return 'background-color:#CF0C29;color:#fff;font-weight:bold;';
    }
  }
}

</script>