商店
var timesheet = new Ext.data.JsonStore(
{
root: 'timesheetEntries',
url: 'php/scripts/timecardEntry.script.php',
storeId: 'timesheet',
autoLoad: true,
fields: [
{ name: 'id', type: 'integer' },
{ name: 'user_id', type: 'integer' },
{ name: 'ticket_number', type: 'integer' },
{ name: 'description', type: 'string' },
{ name: 'start_time', type: 'string' },
{ name: 'stop_time', type: 'string' },
{ name: 'client_id', type: 'integer' },
{ name: 'is_billable', type: 'integer' }
]
}
);
我的 GridPanel 代码的一部分:
columns: [
{
id: 'ticket_number',
header: 'Ticket #',
dataIndex: 'ticket_number'
},
{
id: 'description',
header: 'Description',
dataIndex: 'description'
},
{
id: 'start_time',
header: 'Start',
dataIndex: 'start_time',
renderer: Ext.util.Format.dateRenderer('m/d/Y H:i:s')
}
...
我从服务器收到这个 JSON 字符串:
{
timesheetEntries:[
{
"id":"1",
"user_id":"1",
"description":null,
"start_time":"2010-11-13 11:30:00",
"stop_time":"2010-11-13 15:50:10",
"client_id":null,
"is_billable":"0"
}
我的网格面板渲染良好。但是,我的开始和停止时间列显示为“NaN/NaN/NaN NaN:NaN:NaN”,我不知道为什么。
最佳答案
如果您的数据有"2010-11-13 11:30:00"
,您的格式不应该是'Y-m-d H:i:s'
吗?
编辑: 抱歉,网格配置应该没问题——我指的是您商店字段定义中的 dateFormat
值,它应该是 'Y-m-d H:i:s'
以便您的传入数据可以正确映射到您的列模型。您还应该包括 type: 'date'
。您没有显示您的商店配置,但问题可能是其中一个错误。
关于javascript - ExtJS 3.3 Format.Util.Ext.util.Format.dateRenderer 返回 NaN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4176039/