0
我正在使用ExtJS 4并尝试将JSON文件加载到面板网格中。参考下面的代码:ExtJS 4面板网格无法从URL加载JSON - Firefox和Chrome不起作用
Ext.onReady(function() {
var myStore = new Ext.data.JsonStore({
autoLoad: true,
proxy: {
type: 'ajax',
url : 'http://localhost:8180/PatientVisit/grid-patient.json',
reader: {type: 'json', root: 'patient'}
},
fields: [{name: 'PatientId', type: 'string'}, {name: 'Initial', type: 'string'}, {name: 'SCStatus', type: 'string'}, {name: 'V1Status', type: 'string'}, {name: 'V2Status', type: 'string'}]
});
var grid = new Ext.grid.GridPanel({
id: 'gridPanel',
title : 'Grid example',
width : 250,
height : 250,
renderTo : 'grid-example',
store : myStore,
columns: [
{ header: 'Patient ID',
dataIndex: 'PatientId'
}, { header: 'Initial', dataIndex: 'Initial'},
{ header: 'SCStatus', dataIndex: 'SCStatus'},
{ header: 'V1Status', dataIndex: 'V1Status'},
{ header: 'V2Status', dataIndex: 'V2Status'}
]
});
myStore.load();
});
JSON file:
{"patient":[{"PatientId":"M1000","Initial":"MAS","SCStatus":"Complete","V1Status":"Open","V2Status":"Open"},
{"PatientId":"M573","Initial":"MTZ","SCStatus":"Complete","V1Status":"Complete","V2Status":"Open"},
{"PatientId":"M634","Initial":"MTS","SCStatus":"Open","V1Status":"Open","V2Status":"Open"}
]}
它在IE 9中工作正常。它在Firefox 16.x和Chrome浏览器中加载一个空网格。如果上述代码存在问题,请告诉我。
我看到的一个问题是,你的商店是autoLoad ed,然后你再次调用load() - 但是这只是意味着你正在重新加载商店。它应该仍然有效。也许还有其他配置或代码会干扰? – dbrin