【发布时间】:2011-11-24 07:03:24
【问题描述】:
我有一个带有日期字段和存储的模型,它从 XML 加载,日期字段与字符串相同。 sencha 会自动将其解析为 Date 还是我需要手动解析?
Ext.regModel('News', {
idProperty: 'Id',
fields: [
{ name: 'Id', type: 'int' },
{ name: 'Title', type: 'string' },
{ name: 'PostedOn', type: 'date' },
{ name: 'PostedBy', type: 'string' },
{ name: 'Details', type: 'string' }
]
});
var newsRemoteStore = new Ext.data.Store({
model: 'News',
sorters: [{
property: 'PostedOn',
direction: 'DESC'
}],
proxy: {
type: 'ajax',
url: BaseURL + 'News.php',
reader: {
type: 'xml',
root: 'News',
record: 'New'
}
},
getGroupString: function(record) {
if (record && record.data.PostedOn) {
return record.get('PostedOn').toDateString();
}
else {
return '';
}
}
});
我问是因为日期字段是空的,即使 xml 响应中有日期,例如
<PostedOn>2011-07-04 16:00:19</PostedOn>
【问题讨论】:
标签: model sencha-touch store