2014-10-04 56 views
0

我是新来的Ext JS 我很抱歉,如果我无法解释我的问题妥善Ext JS的面板空的时间字段

我的问题是在网格中的时间字段中显示为空白

它显示该值如果将类型从字段中的日期更改为模型,并禁用渲染函数formatTime。

下面是响应json,模型和视图的一部分。我从另一个工作网站复制了代码。

请告诉我如何能debugg并找到解决方案,这将是可能的原因

的ExtJS的JSON响应4.2 MVC

价值

"actualstarttime":"02:00 AM" 

模式

{name: 'actualstarttime', type: 'date'}, 
所谓

查看

     { 
          header: 'Time', 
          dataIndex: 'actualstarttime', 
          width: 85, 
          renderer: this.formatTime, 

          editor: { 
           xtype: 'timefield', 
           id : 'e_actualstarttime', 
           /*allowBlank: false,*/ 
           minValue: '12:00 AM', 
           maxValue: '23:00 PM', 
           increment: 30, 
           anchor: '100%', 
           editable : false, 
           format: 'h:i A', 
           submitFormat: 'h:i A', 
           listeners: { 
            change: function(roweditor, changes, record, rowIndex) { 
             me.calculateInterval(roweditor, changes, record, rowIndex); 
            }, 
            afterrender: function(roweditor, changes, record, rowIndex) { //TECHNOKRAFTS: Added Listner to apply validation depending on the status 
             me.checkstatusvalidation(roweditor, changes, record, rowIndex); 
            } 
           } 
          } 
         } 

Formattime功能使

formatTime : function (value){ 
    return value ? Ext.Date.dateFormat(value, 'g:i A') : ''; 
} 

回答

1

您需要将dateFormat添加到您的字段定义。

Ext.define("Model", { 
     extend: "Ext.data.Model", 
     fields: [{ 
      name: "actualstarttime", 
      format: "h:i A" 
     }] 
    }); 

Demo

+0

非常感谢博扬德维克,您的解决方案解决了我的问题 – 2014-10-05 13:55:21