如题,在正常的form中类型为textfield中使用正常,为什么在editorgrid中就报错,我在editorgrid中的代码如下:{dataIndex:"end_date",header:"时间",width:110,align:'right',sortable:true,
        editor:new Ext.form.TextField({cls:"Wdate",listeners:{'focus':function(){WdatePicker({dateFmt:'yyyy-M-d'})}}})},错误提示:htmlfile: 由于该控件目前不可见、未启用或其类型不允许,因此无法将焦点移向它。

解决方案 »

  1.   

    这类错误往往是由于组件处于隐藏状态或disabled状态时 执行了focus处理 楼主看看有没有这种情况?
      

  2.   

    错误的确是由于focus引起,那该怎么修改呢,我在这个editgrid里想使用这个日期控件
      

  3.   

    ext中有Ext.form.DateField,可以扩展一下试试看。
      

  4.   


    Ext.form.DateTimeField = Ext.extend(Ext.form.TriggerField, {
    /**
     * @param {Array} date97
     * @type 
     */
    dateConfig:null,
    /**
     * @param {Boolean} 
     */
    time:false,
    triggerClass : 'x-form-date-trigger',
    defaultAutoCreate : {tag : "input",type : "text",size : "10",autocomplete : "off"},
    initComponent : function() {
    Ext.form.DateField.superclass.initComponent.call(this);
    this.initDate97js();
    this.initDateConfig();
    },
    onTriggerClick : function(e) {//
    if (this.disabled||this.readOnly) {
    return;
    }
    this.onFocus({});
    var bodyWidth = document.body.clientWidth;
    var xC = document.body.clientWidth - e.xy[0] - this.width;
    var yC = document.body.clientHeight - e.xy[1] - this.height; 
    var x=0;
    var y=0;
    if (xC > 0)
    x = e.xy[0];
    else
    x = document.body.clientWidth - this.width - 4; if (yC > 0)
    y = e.xy[1];
    else
    y= document.body.clientHeight - this.height - 4;
    // this.dateConfig['position']={left:e.xy[0],top:e.xy[1]};
    WdatePicker(this.dateConfig);
    },
    initDate97js:function(){
    var obj=this;
    if(!document.getElementById("$date97js")){
     var  script  =  document.createElement("script");   
      script.setAttribute("type",   "text/javascript");   
      script.setAttribute("src",   MCLONIS+"/js/date97/WdatePicker.js");
      script.setAttribute("id","$date97js");
      try   
      {   
      document.getElementsByTagName("head")[0].appendChild(script);
      script.onload = script.onreadystatechange = function() {
        if (script.readyState && script.readyState != 'loaded' && script.readyState != 'complete') 
                return; 
             script.onreadystatechange = script.onload = null; 
               WdatePicker(1);
     }
      }catch(e){}
    }
    },
    initDateConfig:function()
    {
    if(!this.dateConfig)
    this.dateConfig=new Array();
    if(!this.dateConfig['el'])
    this.dateConfig['el']=this.id;
    if(this.time)
    this.addDateConfig("dateFmt",'yyyy-MM-dd HH:mm:ss');
    else
    if(!this.dateConfig["dateFmt"])
    this.dateConfig["dateFmt"]='yyyy-MM-dd';
    if(!this.dateConfig["skin"])
    this.dateConfig["skin"]='ext';
    },
    addDateConfig:function(name,value)
    {
    this.removeDateConfig(name);
    this.dateConfig[name]=value;
    },
    removeDateConfig:function(name){
    for (var i = 0; i < this.dateConfig.length; i++) {
    var temp = this.dateConfig[i];
    if (temp && temp.split(':')[0] == name) {
    this.dateConfig.pop(i);
    return;
    }
    }
    },
    setDateConfig:function(config)
    {
    this.dateConfig=config;
    this.initDateConfig();
    }
    });