ExtjsTimeField: code for displaying the normal time format _ extjs-js tutorial

Source: Internet
Author: User
The Date and time formats of json returned by the background are usually similar to those of & quot; Date (1309200300000) & quot, the result is not displayed normally in TimeField. If you want to display the result correctly, the general method is to change the background code and convert the date and time format to string to return the result. The solution is to override the setValue of TimeField, the Code is as follows:

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 timefield values greater than 8 must be in json
Var jsondate = eval ("new" + v. substr (1, v. length-2). toLocaleTimeString ();
Jsondate = jsondate. length = 8? Jsondate. substr (0, 5): '0' + jsondate. substr (0, 4); // toLocaleTimeString is relatively retarded. If the returned hour is less than 10 hours, only one digit is returned.
Return jsondate;
}
Return v;
}
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.