2017-07-12 6 views
0

私はinitComponentにURLを持っています:this.myStore.getProxy().url = MY_URI + record.data.id;、ここでレコードは選択したレコードです。Extjsのグリッド内のURLからデータを読み込むには?

私はChromeのネットワークレスポンスに次のように取得GET URLから結果:現在、グリッド内

{ 
    "result": { 
     "id": "15", 
     "height": "600", 
     "width": "600", 
     "squares": [{ 
      "id": 25, 
      "height": 50, 
      "width": 50 
     }, { 
      "id": 26, 
      "height": 50, 
      "width": 50 
     }] 
    } 
} 

:私は正方形の値がオブジェクトを取得していないstore: this.myStoredataIndex: 'id' or 'dataIndex: 'height' or ' dataIndex: 'width'、他のもの、例えば、高さ列表示および のようなものがあります。

四角形の情報をグリッドに表示するにはどうすればよいですか?

ありがとうございます。

+0

どのように正確にあなたがグリッドの正方形の情報を表示したいですか?いくつかのデータは別の列にありますか?または、行のエキスパンダーですか? – scebotari66

+0

scebotari66 @、例えば: カラム:[ {テキスト:、dataIndex 'スクエア': 'ID'}、 {テキスト: '高さ'、dataIndex: '高さ'}、 {テキスト: '幅'、 dataIndex: 'width'} ] –

+0

プロキシリーダーの 'rootProperty'設定を" squares "に設定すると問題が解決されますか? – scebotari66

答えて

0

はあなたreader#rootProperty

'result.squares'に設定します。

Ext.create('Ext.data.Store', { 
    storeId: 'squareStore', 
    fields: ['id', 'height', 'width'], 
    autoLoad: true, 
    proxy: { 
     type: 'ajax', 
     url: 'data1.json', // your url here 
     reader: { 
      type: 'json', 
      rootProperty: 'result.squares' 
     } 
    } 
}); 

Ext.create('Ext.grid.Panel', { 
    title: 'Square', 
    store: Ext.data.StoreManager.lookup('squareStore'), 
    columns: [{ 
     text: 'id', 
     dataIndex: 'id' 
    }, { 
     text: 'Height', 
     dataIndex: 'height', 
     flex: 1 
    }, { 
     text: 'Width', 
     dataIndex: 'width' 
    }], 
    height: 200, 
    width: 400, 
    renderTo: Ext.getBody() 
}); 

フィドル:https://fiddle.sencha.com/#view/editor&fiddle/236t

関連する問題