ExtJS 4 を使用しており、JSON ファイルを Panel Grid にロードしようとしています。以下のコードを参照してください。
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 ブラウザでは空のグリッドをロードします。上記のコードに問題がある場合はお知らせください。