1 2 3 4 5 6 7 8 9 10 11 12 | .calendarIcon { display: block; width: 24px; height: 22px; background: url("/images/calendar-icon.png") no-repeat 0 0 transparent; cursor: pointer; margin-left: 5px; } .calendarIcon:hover { background-position: 10 0; } |
1 2 3 4 5 | <div class="myDateTextBox"> <div dojoAttachPoint="dateTextField" dojoType="dijit/form/DateTextBox"></div> <div dojoAttachEvent="onclick:popupCalendar" class="calendarIcon"></div> <div dojoAttachPoint="inputFormat" class="inputFormat"></div> </div> |
1 2 3 4 5 6 7 8 9 10 11 | define([ "dojo/_base/declare", "dojo/_base/config", "dojo/_base/lang", "dojo/date/locale", "dojo/dom-class", "dijit/_Contained", "dijit/_WidgetBase", "dijit/_TemplateMixin", "dojo/text!./templates/ MyDateTextBox.html" ],function(declare, config, lang, locale, domClass, contained, widgetBase, templateMixin,template){ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | define([ "dojo/_base/declare", "dojo/_base/config", "dojo/_base/lang", "dojo/date/locale", "dojo/dom-class", "dijit/_Contained", "dijit/_WidgetBase", "dijit/_TemplateMixin", "dojo/text!./templates/ MyDateTextBox.html" ],function(declare, config, lang, locale, domClass, contained, widgetBase, templateMixin,template){ return declare("common.MyDateTextBox", [contained, widgetBase, templateMixin],{ templatePath: template, dateTextField: null, // DateTextBox widget serverDatePattern: 'dd-MM-yyyy', errorNode: null, serverFormat: { selector: 'date', datePattern: 'dd-MM-yyyy', //服务器端是 oracle 日期格式 locale: 'en-us' }, postCreate: function() { this.dateTextField.set("constraints", { selector: "date", formatLength: "short") }; this.dateTextField.set("lang", config.locale); this.dateTextField.set("required", true); this.dateTextField.displayMessage = lang.hitch(this, function(message) { if (message) { this.setError(); } else { this.removeError(); } }); }, popupCalendar: function() { this.dateTextField.focus(); this.dateTextField.loadAndOpenDropDown(); }, setValue: function(value) { this.dateTextField.set("value", locale.parse(value, this.serverFormat)) }, getValue: function() { return locale.format(this.dateTextField.get("value"), this.serverFormat }, validate: function () { this.removeError(); if (!this.dateTextField.isValid()) { this.setError(); return false; } else { return true; } }, setError: function(serverErrorMessageIgnored) { this.errorNode.innerHTML = this._datePattern(); domClass.removeClass(this.errorNode, "hidden"); domClass.addClass(this.dateTextField.domNode, "ls-inputError"); }, removeError: function() { this.errorNode.innerHTML = ""; domClass.addClass(this.errorNode, "hidden"); domClass.removeClass(this.dateTextField.domNode, "ls-inputError"); }, }); |
1 2 3 4 5 6 7 | <td> <div dojoAttachPoint="dateTextField" dojoType="dijit/form/DateTextBox"></div> </td> <td> <div dojoAttachPoint="calendarButton" dojoAttachEvent="onclick:popupCalendar" class="calendarIcon"></div> </td> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |