mxwhh 2009-07-03 20:47
浏览 362
已采纳

关于timefield的maxValue的赋值问题

Ext.Ajax.request( {
url :'../m/Getendtime.jsp',
method :'POST',
params : {
starttime : querystarttime,
user_id : user_id
},
success : function(responseObject) {
var ett = Ext.util.JSON.decode(responseObject.responseText);
ettd = ett['data'];
var etm=Ext.util.Format.date(ettd, "H:i");
}

    })

从上面的代码中得到了etm的值,我想把这个值传给timefield(id:et)控件中的maxValue属性,请问该怎么传?

我曾试过在上面代码的最后一句后面加上Ext.getCmp("et").setMaxValue(etm);但是提示timefield没有setMaxValue方法,查阅API后发现timefield确实没有该方法,而datefield有。

[b]问题补充:[/b]
我在程序的开始添加了以下代码
Ext.override( Ext.form.TimeField,
{
setMaxValue: function (time)
{this.maxValue = time;},
getMaxValue: function(){return this.maxValue}
});
然后在使用Ext.getCmp("et").setMaxValue(et)时得不到我要的效果(注:直接使用maxValue:et 可以),使用Ext.getCmp("et").getMaxValue()可以得到我要的时间。为什么??

  • 写回答

10条回答 默认 最新

  • iteye_10013 2009-07-05 00:35
    关注

    试下吧,刚写的,我本地测试过的:

    [code="javascript"]
    function test3(){
    Ext.override( Ext.form.TimeField,{

    setRangeValue : function(minValue,maxValue){

    if(!Ext.isEmpty(minValue)){

    this.minValue = this.parseDate(minValue);

    }

    if(!Ext.isEmpty(maxValue)){

    this.maxValue = this.parseDate(maxValue);

    }

    var min = this.parseDate(this.minValue);

    if(!min){

    min = new Date(this.initDate).clearTime();

    }

    var max = this.parseDate(this.maxValue);

    if(!max){

    max = new Date(this.initDate).clearTime().add('mi', (24 * 60) - 1);

    }

    var times = [];

    while(min <= max){

    times.push([min.dateFormat(this.format)]);

    min = min.add('mi', this.increment);

    }

    this.store.loadData(times);

    }

    });

    var t = new Ext.form.TimeField({
    minValue: '9:00 AM',
    maxValue: '6:00 PM',
    increment: 30,
    renderTo:document.body
    });
    var b = new Ext.Button({
    renderTo:document.body,
    text:'设置结束时间为20:00',
    handler:function(){
    t.setRangeValue(null,'10:00 PM')
    }
    })
    }
    Ext.onReady(test3);
    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(9条)

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?