首页 > 代码库 > yui--datatable 行添加格式

yui--datatable 行添加格式

 

采用formatter


 

 

YAHOO.widget.DataTable.Formatter.changeLight=function(elCell, oRecord, oColumn, oData){
      elCell.innerHTML = "<img src=http://www.mamicode.com/‘../MonitorManage/images/gray_lamp.png‘>";
};

{key:"ONLINESTATUS", label:"状态",width:30,resizeable:true,sortable:true,formatter:"changeLight"},

 

 

 

js操作


 

通过获取到行记录的id然后操作

 

var myTable = Map.realYUIDataTable;
var recordsSet = myTable.getRecordSet();
var records = recordsSet.getRecords();
for(var s=0; s<records.length; s++){
   var alarmStatusCell = records[s]._oData.ALARMSTATUS;
   var id = records[s].getId();
   if(alarmStatusCell!="" && alarmStatusCell!="00000000000000000000000000000000" && alarmStatusCell!=null){
       $("#"+id).attr(‘style‘,‘background:#FF9797;‘);
      }else{
       $("#"+id).attr(‘style‘,‘‘);
       }
            
}