2016-11-22 177 views

回答

1

將這個數據源中的onCurrentElementChange事件與網格相關:

if (this.getCurrentElement()!==null){ 
 
\t //format time value in data grid 
 
\t $$('dataGrid1').column('timeStamp').setRenderer( 
 
     function(myCell) { 
 
     if (myCell.value > 0) 
 
      return formatSeconds(myCell.value);//formatting using the ultility function 
 
\t } 
 
\t); \t \t 
 
}

然後在你的代碼中formatSeconds功能:

function formatSeconds(milliseconds) { 
 
\t  var date = new Date(1970,0,1); 
 
\t  date.setSeconds(milliseconds/1000); 
 
\t  return date.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"); 
 
\t }