Ext DataView tpl

  var tpl = new Ext.XTemplate
   (
   '<tpl for=".">',
     '<div class="view-item" >',
      '<table width="100%">',
       '<tr>',
        '<td width="16" class="{[this.getTxtStyle(values)]}">{#}</td>',
        '<td width="16" class="{[this.getTxtStyle(values)]}">',
         '<tpl if=" ATTACHMENT!=null ">',
          '<img src="../images/ico-attch.gif" width=16 height=16/>',
         '</tpl>',
        '</td>',
        '<td width="16" class="{[this.getTxtStyle(values)]}">',
         '<tpl if=" FEEDBACKSTATUS==1">',
          '<img src="../images/taskplan/task_lvl_2.gif" width=16 height=16/>',
         '</tpl>',
         '<tpl if=" FEEDBACKSTATUS==2">',
          '<img src="../images/taskplan/task_lvl_3.gif" width=16 height=16/>',
         '</tpl>',
         '<tpl if=" FEEDBACKSTATUS==3">',
          '<img src="../images/taskplan/task_lvl_1.gif" width=16 height=16/>',
         '</tpl>',
         '<tpl if=" FEEDBACKSTATUS==4">',
          '<img src="../images/taskplan/task_lvl_4.gif" width=16 height=16/>',
         '</tpl>',
         '<tpl if=" FEEDBACKSTATUS==5">',
          '<img src="../images/ico-light-red.gif" width=16 height=16/>',
         '</tpl>',
        '</td>',
        '<td  class="{[this.getTxtStyle(values)]}">{FEEDBACKUSER}</td>',
        '<td width="150" class="txt">{time}</td>',
       '</tr>',
      '</table>',
     '</div>',
   '</tpl>',
   '<div class="x-clear"></div>',
   {
    isRead : function(values)
    {
     return '<img src="/images/communication/feedback_isread_'
      + values.ISREAD +
      '.png" width=16 height=16/>';
    }
   },
   { 
               getTxtStyle : function (values)
               { 
              if(values.OVERTIME == "超期" )
               { 
      return 'redtxt'; 
                 }
                 else
                 {
      return 'txt'; 
                 }         
               } 
           }
  );
  this.dataView = new Ext.DataView
  ({
   cls : 'oa-dataview',
   style : 'overflow:auto',
    tpl : tpl,
    itemSelector : 'div.view-item',
    store : this.store,
    multiSelect : false,
    singleSelect : true,
    overClass : 'view-over',
    selectedClass : 'view-selected',
    deferEmptyText : '暂无',
    prepareData : function(data,num,record)
    {
     data.time = Ext.util.Format.javaDate(data.FEEDBACKTIME,'Y-m-d H:i');
     return data;
    }
  });

你可能感兴趣的:(view)