Extjs shows the problem after the time taken from the database is converted to JSON

Source: Internet
Author: User

The time taken from the database in the background is formatted in JSON format and then transmitted to gridpanel. The time is changed to the format of/Date (32331121223)/. Then, the following processing is required for normal display:
In Copy codeThe Code is as follows: var record = Ext. data. Record. create ([
{Name: 'publicdate', mapping: 'publicdate', dateFormat: 'Y-m-d', convert: function (v ){
If (v = null ){
Return null;
}
Var d = new Date ();
Var str = v. toString ();
Var str1 = str. replace ("/Date (","");
Var str2 = str1.replace (")/","");
Var dd = parseInt (str2 );
D. setTime (dd );
Return d;
}}
]);

Then in:Copy codeThe Code is as follows: var cm = new Ext. grid. ColumnModel ([
{Header: 'publication time', dataIndex: 'publicdate', width: 120, align: 'center', renderer: Ext. util. format. dateRenderer ('Y-m-d ')}
]);

This will display normally, for example, 2012-11-19,

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.