我在代码中找到问题时遇到了一些麻烦,所以我想找到第二双眼睛。
代码:
var logStore = new Ext.data.JsonStore({
autoLoad: true,
url: 'inc/interface/config.php?list=messages',
root: 'logs',
id: 'ID',
fields: ['ReceivedAt', 'Message']
});
var logGrid = new Ext.grid.GridPanel({
region: 'center',
store: logStore,
autoWidth: true,
height: 1000,
colModel: new Ext.grid.ColumnModel({
columns:[
{id: 'received', header: 'Received', dataIndex: 'ReceivedAt', width: 250},
{id: 'message', header: 'Logs', dataIndex: 'Message', width: 750}
]
}),
});
var mainViewport = new Ext.Viewport({
layout: 'border',
items:[logGrid, searchPanel]
});
上面的代码是我的界面,虽然我在加载时没有收到任何错误,但我无法将我的数据存储在网格中。我相信我的商店/网格是直接配置的,但这就是我在这里的目的。
以下是我从商店加载我的代码得到的回复:
{"logs":[
{"ID":"1","ReceivedAt":"2010-07-07 11:37:42","Message":"Apr 9 00:00:02 dh1 dhcpd: Added new forward map from blahhhhhhh to 10.193.blah.blah"},
{"ID":"2","ReceivedAt":"2010-07-07 11:37:42","Message":"Apr 9 00:00:02 dh1 dhcpd: added reverse map from 248.240.blah.blah.in-addr.arpa. to blahhhhhhhh"},
{"ID":"3","ReceivedAt":"2010-07-07 11:37:42","Message":"Apr 9 00:00:02 dh1 dhcpd: DHCPREQUEST for 10.193.blah.blah from aa:bb:cc:dd:ee:ff (blahhhhhh) via 10.193.blah.blah"}
]}
由于显而易见的原因编辑。
我所做的是拿出“日志”并显示日期并且工作正常;然后我尝试了日志,但失败了。数据存储在mysql中,如:
Apr 9 00:00:02 dh1 dhcpd:从blah.wifi.blah添加了新的转发地图到10.193.blah.blah
我认为JS在解析数据时遇到问题?你们觉得怎么样?
感谢您的帮助!
答案 0 :(得分:0)
你确定商店正在装货吗?我把它放进去了,它按照我的预期跑了?
Ext.onReady(function(){
var logStore = new Ext.data.JsonStore({
root: 'logs',
id: 'ID',
fields: ['ReceivedAt', 'Message'],
data: {
"logs": [{
"ID": "1",
"ReceivedAt": "2010-07-07 11:37:42",
"Message": "Apr 9 00:00:02 dh1 dhcpd: Added new forward map from blahhhhhhh to 10.193.blah.blah"
}, {
"ID": "2",
"ReceivedAt": "2010-07-07 11:37:42",
"Message": "Apr 9 00:00:02 dh1 dhcpd: added reverse map from 248.240.blah.blah.in-addr.arpa. to blahhhhhhhh"
}, {
"ID": "3",
"ReceivedAt": "2010-07-07 11:37:42",
"Message": "Apr 9 00:00:02 dh1 dhcpd: DHCPREQUEST for 10.193.blah.blah from aa:bb:cc:dd:ee:ff (blahhhhhh) via 10.193.blah.blah"
}]
}
});
var logGrid = new Ext.grid.GridPanel({
region: 'center',
store: logStore,
colModel: new Ext.grid.ColumnModel({
columns: [{
id: 'received',
header: 'Received',
dataIndex: 'ReceivedAt',
width: 250
}, {
id: 'message',
header: 'Logs',
dataIndex: 'Message',
width: 750
}]
}),
});
var mainViewport = new Ext.Viewport({
layout: 'border',
items: [logGrid]
});
});
尝试在商店中添加加载事件,以查看它是否实际正在正确加载。