Home > Web Front-end > JS Tutorial > Extjs TimeField code to display normal time format_extjs

Extjs TimeField code to display normal time format_extjs

WBOY
Release: 2016-05-16 18:05:31
Original
1105 people have browsed it

If you want to display it correctly, the general method is to change the background code so that the date and time format changes to string return. My solution is to rewrite the setValue of TimeField. The specific code is as follows:

Copy code The code is as follows:

Ext.override(Ext.form.TimeField, {
getValue: function () {
return this.value;
},
setValue: function (v) {
this.value = v;
this.setRawValue(this.formatValue(v));
return this;
},
formatValue: function (v) {
if (v.length>8) { //The maximum number of timefields cannot exceed 8. If the number is greater than 8, it must be
var jsondate = eval in json ("new " v.substr(1, v.length - 2)).toLocaleTimeString();
jsondate = jsondate.length == 8 ? jsondate.substr(0, 5) : '0' jsondate.substr( 0, 4); //toLocaleTimeString is relatively stupid, if the hour returned is less than 10 hours, there is only 1 digit
return jsondate;
}
return v;
}
});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template