Extjs時間顯示問題

來源:互聯網
上載者:User

JSON資料返回的一行的資料如下 :兩種情況

(1)

{"comm":0,"empno":7876,"ename":"ADAMS","hiredate":"1998-12-12 08:25:36","job":"CLERK","mgr":7788,"sal":1100}

(2)

{"comm":0,"empno":7876,"ename":"ADAMS","hiredate":{"date":12,"day":6,"hours":8,"minutes":25,"month":11,"nanos":0,"seconds":36,"time":913422336000,"timezoneOffset":-480,"year":98}

JSonReader中讀取pubdate屬性的設定代碼如下:

var myreader=new Ext.data.JsonReader({idProperty: 'empno',root:'data',totalProperty: 'total',fields: [        {name: 'empno'},        {name: 'ename'},(1)        {name: 'hiredate',type:'date',dateFormat :'Y-m-d H:i:s'}(2)//        {name: 'hiredate',mapping:'hiredate.time',type:'date',dateFormat:'time'}    ]});

reader中的dateFormat格式對應從後台傳過來點格式。下面在grid中顯示列中則可以隨便你怎麼格式

Grid的columnmodel設定如下: 

function formatDate(value){        return value ? value.dateFormat('Y-m-d') : '';    }

            {//            xtype:'datecolumn',//            format:'Y-m-d h:i:s',                header   : 'hiredate',                 width    : 200,                 sortable : true,                 dataIndex: 'hiredate',                renderer:formatDate,//                renderer:Ext.util.Format.dateRenderer('Y-m-d'),                editor: new fm.DateField({//                    allowBlank: false                })            }

注釋的都是可以隨便顯示

alert(Ext.util.Format.date(name,'Y-m-d'));



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.