[英]How to load data from an URL in a grid in Extjs?
我在initComponent中有一個網址,網址為: this.myStore.getProxy().url = MY_URI + record.data.id;
,其中記錄是我選擇的記錄。
作為GET網址的結果,我在Chrome的網絡響應中得到以下內容:
{
"result": {
"id": "15",
"height": "600",
"width": "600",
"squares": [{
"id": 25,
"height": 50,
"width": 50
}, {
"id": 26,
"height": 50,
"width": 50
}]
}
}
當前在網格中的時間: store: this.myStore
和store: this.myStore
dataIndex: 'id' or 'dataIndex: 'height' or ' dataIndex: 'width'
我沒有得到squares對象的值,但是其他的卻得到了“ 高度”列顯示600而不是 50 。
如何在網格中顯示正方形的信息?
謝謝。
將您的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()
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.