亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Extjs TimeField 顯示正常時(shí)間格式的代碼

 更新時(shí)間:2011年06月28日 23:55:28   作者:  
由后臺(tái)返回的json的日期時(shí)間格式中,往往都是 類(lèi)似 "\/Date(1309200300000)\/"的日期時(shí)間格式,結(jié)果導(dǎo)致無(wú)法正常在TimeField中顯示
如果想正確顯示,一般的方法都是改后臺(tái)代碼,使日期時(shí)間格式變?yōu)閟tring返回,我解決的方法是重寫(xiě)TimeField 的setValue ,具體代碼如下:
復(fù)制代碼 代碼如下:

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) { //timefield最大不超過(guò)8個(gè) 大于8個(gè)的肯定是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比較弱智,返回的如果小時(shí)是小于10 小時(shí)位就只有1位
return jsondate;
}
return v;
}
});

相關(guān)文章

最新評(píng)論