[英]How to load data from an URL in a grid in Extjs?
I have an url in initComponent by: this.myStore.getProxy().url = MY_URI + record.data.id;
我在initComponent中有一个网址,网址为:
this.myStore.getProxy().url = MY_URI + record.data.id;
, where record is my selected record. ,其中记录是我选择的记录。
As a result from the GET url I get the following in Chrome's Network Response : 作为GET网址的结果,我在Chrome的网络响应中得到以下内容:
{
"result": {
"id": "15",
"height": "600",
"width": "600",
"squares": [{
"id": 25,
"height": 50,
"width": 50
}, {
"id": 26,
"height": 50,
"width": 50
}]
}
}
Currently in the grid when: store: this.myStore
and dataIndex: 'id' or 'dataIndex: 'height' or ' dataIndex: 'width'
I don't get the values of the squares object, but the other ones, for example the Height column displays 600 and not 50 . 当前在网格中的时间:
store: this.myStore
和store: this.myStore
dataIndex: 'id' or 'dataIndex: 'height' or ' dataIndex: 'width'
我没有得到squares对象的值,但是其他的却得到了“ 高度”列显示600而不是 50 。
How can I display the squares' information in the grid? 如何在网格中显示正方形的信息?
Thank you. 谢谢。
Set your reader#rootProperty
to 'result.squares'
将您的
reader#rootProperty
设置为'result.squares'
Example: 例:
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()
});
Fiddle: https://fiddle.sencha.com/#view/editor&fiddle/236t 小提琴: https : //fiddle.sencha.com/#view/editor&fiddle/236t
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.