0

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 ブラウザでは空のグリッドをロードします。上記のコードに問題がある場合はお知らせください。

4

1 に答える 1

0

問題を解決しました。これは、クロス ドメイン AJAX 呼び出しの問題でした。HTML ファイルがサーバー ディレクトリの外にありました。サーバーに対して AJAX 呼び出しを行い、JSON データを取得します。Firefox と Chrome では、この呼び出しは許可されていません。IEは許可しており、正常に動作します。

于 2012-11-01T20:21:48.133 に答える