修改Ext.form.DateField只選擇年月

來源:互聯網
上載者:User

修改Ext.form.DateField:<br />onTriggerClick : function()...{<br />if(this.disabled)...{<br />return;<br />}<br />if(this.menu == null)...{<br />this.menu = new Ext.menu.DateMenu();<br />}<br />Ext.apply(this.menu.picker, ...{<br />minDate : this.minValue,<br />maxDate : this.maxValue,<br />disabledDatesRE : this.ddMatch,<br />disabledDatesText : this.disabledDatesText,<br />disabledDays : this.disabledDays,<br />disabledDaysText : this.disabledDaysText,<br />format : this.format,<br />minText : String.format(this.minText, this.formatDate(this.minValue)),<br />maxText : String.format(this.maxText, this.formatDate(this.maxValue)),<br />input: this//davi<br />});<br />this.menu.on(Ext.apply(...{}, this.menuListeners, ...{<br />scope:this<br />}));</p><p>this.menu.picker.setValue(this.getValue() || new Date());<br />this.menu.show(this.el, "tl-bl?");<br />}<br />...</p><p>修改Ext.DatePicker:<br />...<br />onRender : function(container, position)...{<br />//增加id:date_daysdate_bottom 用來隱藏days davi<br />var m = [<br />'<table cellspacing="0">',<br />'<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'">*</a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'">*</a></td></tr>',<br />'<tr id="date_days"><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'];</p><p>...<br />m[m.length] = '</tr></tbody></table></td></tr><tr id="date_bottom"><td colspan="3" class="x-date-bottom" align="center"></td></tr></table>';<br />...<br />if(Ext.isIE)...{<br />this.el.repaint();<br />}<br />this.update(this.value);<br />...<br />//如果日期格式為Y年m月 則不顯示日 davi<br />if(this.format == 'Y年m月')...{<br />Ext.get('date_days').hide();<br />Ext.get('date_bottom').hide();<br />}<br />/**//**/<br />},<br />update : function(date)...{<br />...<br />for(; i < 42; i++) ...{<br />textEls[i].innerHTML = (++extraDays);<br />d.setDate(d.getDate()+1);<br />cells[i].className = "x-date-nextday";<br />setCellClass(this, cells[i]);<br />}</p><p>//如果日期格式為Y年m月 則不顯示日 davi<br />if(this.format == 'Y年m月' && this.getValue() != date)...{<br />this.input.setValue(date);<br />this.input.fireEvent("select", date, this.input);<br />}<br />/**//**/<br />...<br />}

 

用法:<br />var date = new Ext.form.DateField(...{<br />...<br />format: 'Y年m月',<br />...<br />});<br />date.applyTo('date');<br />date.on('select',function()...{...});

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.