ExtJS Grid列渲染

// 根据时间段显示不同图标
// <1>grid列:
{id:'cardStatusIcon',header:'',dataIndex:'cardStatus',
width:50,align:'center',renderer:renderer_Meta_expireDate_icon,resizable:false,sortable:false},
// <2>列判断
function renderer_Meta_expireDate_icon(value, cellmeta, record,rowIndex, columnIndex, store){
    
    //------------------------------Configuration------------------------BEG
    // Target cell set
    var cellID             = 'Meta_expireDate';
    
    // Day count config
    var intervalZero       = 0;                          // Include
    var intervalDay30      = 30;                         // Don't include
    var intervalDay60      = 60;                         // Don't include
    var intervalDay90      = 90;                         // Don't include
    
    // Image path config
    var iconDirPath          = "/images/icons/silk/";
    var iconRedName          = "remind_red.png";
    var iconGreenName        = "remind_green.png";
    var iconYellowName       = "remind_yellow.png";
    var iconInvalid          = "remind_invalid.png";
    var iconWarningGreen     = "warning_blue.png";
    
    var iconRedPath          = iconDirPath + iconRedName;
    var iconGreenPath        = iconDirPath + iconGreenName;
    var iconYellowPath       = iconDirPath + iconYellowName; 
    var iconInvalidPath      = iconDirPath + iconInvalid;
    var iconWarningGreenPath = iconDirPath + iconWarningGreen;
    
    // Return element config
    var returnHtmlHead = "<img src='";
    var returnHtmlFoor = "'/>";
    var returnHtmlInfo = "";
    //------------------------------Configuration------------------------END
    
    // Current date
    var currentDate = new Date();
    var curYear     = currentDate.getFullYear();
    var curMonth    = currentDate.getMonth();
    var curDay      = currentDate.getDate();
    
    // Card end date
    var cardEndDate  = record.get(cellID);
    var cardEndYear  = cardEndDate.substring(0,4);
    var cardEndMonth = eval(cardEndDate.substring(5,7)-"1");
    var cardEndDay   = cardEndDate.substring(8,10);
    
// Example: "2013-04-17" - "2013-04-19" interval 2 day,staring clock point "00:00"
var intervalFact=((Date.parse(cardEndMonth+'/'+cardEndDay+'/'+cardEndYear)
                     - Date.parse(curMonth+'/'+curDay+'/'+curYear))/86400000);   
    var temp = "";
    
    // Day >= 0 && Day <30
    if(intervalFact >= intervalZero && intervalFact < intervalDay30){
        temp = iconRedPath;
    
 }else if(intervalFact >= intervalDay30 && intervalFact < intervalDay60){
         temp = iconYellowPath;
     }else if(intervalFact >= intervalDay60 && intervalFact < intervalDay90){
         temp = iconWarningGreenPath; 
     }else if(intervalFact < intervalZero){
         temp = iconInvalidPath; 
     }else{
         temp = iconGreenPath; 
     }
    returnHtmlInfo = returnHtmlHead + temp + returnHtmlFoor;
return returnHtmlInfo;
}



你可能感兴趣的:(ExtJS Grid列渲染)