【问题标题】:add 15 minutes to timefield将 15 分钟添加到时域
【发布时间】:2013-11-14 08:25:18
【问题描述】:

我使用两个时间域。一个是开始时间,另一个是结束时间。当我在开始时间选择一个时间时,我将此值加载到结束时间:

{
xtype: 'timefield',
flex: 1,
margins: '10',
maxHeight: 25,
maxWidth: 100,
fieldLabel: '',
labelAlign: 'top',
name: 'startTijd',
allowBlank: false,
altFormats: 'G:i',
format: 'G:i',
listeners: {
    change: {
        fn: me.onTimefieldChange,
        scope: me
    }
}

}

这是监听器的函数

onTimefieldChange: function (field, newValue, oldValue, eOpts) {
  Ext.getCmp('eindTijd').setValue(newValue);
}

但我想要的是,当我选择 starttime = 14:00 时,endtime 将自动增加一步,在这种情况下为 14:15。我尝试将 15 添加到 newValue 但这会将 15 添加到 GMT

【问题讨论】:

    标签: extjs timefield


    【解决方案1】:

    Ext 为这种操作提供了Ext.Date.add。使用您的代码,将类似于:

    onTimefieldChange: function (field, newValue, oldValue, eOpts) {
        var convertedValue = Ext.isEmpty(newValue)
            ? null
            : Ext.Date.add(newValue, Ext.Date.MINUTE, 15);
        Ext.getCmp('eindTijd').setValue(convertedValue);
    }
    

    【讨论】:

      猜你喜欢
      • 2013-12-31
      • 2017-08-28
      • 2017-08-18
      • 1970-01-01
      • 2015-09-28
      • 2013-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多