[英]ExtJS4 JSON data not populating Ext.grid.Panel
I've looked at numerous posts regarding this issue, but I'm still having problems for some reason. 我看过许多有关此问题的帖子,但由于某些原因我仍然遇到问题。 I have even tried to create a Panel with minimal data, but still no luck.
我什至试图用最少的数据创建一个面板,但是仍然没有运气。 This is really racking my brain.
这真让我大吃一惊。 Below is the code that I'm working with:
以下是我正在使用的代码:
Ext.onReady(function () {
var proxy = new Ext.data.HttpProxy({
url: path/to/app
api: {
load: path/to/app
}
});
var reader = new Ext.data.JsonReader({
successProperty : 'success',
idProperty : 'id',
root : 'data',
fields : [{name:'id', type: 'int'}]
});
var writer = new Ext.data.JsonWriter({
encode: false,
writeAllFields: true
});
var store = new Ext.data.Store({
autoLoad : true,
autoSync : true,
root : 'data',
restful : true,
fields : [{name: 'id'}],
proxy : proxy,
reader : reader,
writer : writer
});
Ext.create('Ext.grid.Panel', {
renderTo : 'gadgetview',
store : store,
columns : [{
header : 'ID',
text : 'ID',
dataIndex : 'id',
width : 50
}],
height : 200,
width : 450,
title : 'Example'
});
});
The response from the server is: 服务器的响应为:
{"data":[{"id":1}], "success":true}
I'm hoping that it's something that's readily apparent. 我希望这是显而易见的。
Your configurations are messed up. 您的配置搞砸了。 The reader/writer are properties on the proxy.
读取器/写入器是代理上的属性。 The root is a property on the reader.
根是阅读器上的属性。
Ext.onReady(function() {
var store = new Ext.data.Store({
autoLoad: true,
fields: [{
name: 'id'
}],
proxy: {
type: 'ajax',
url: 'myurl',
reader: {
type: 'json',
root: 'data'
}
}
});
Ext.create('Ext.grid.Panel', {
renderTo: 'gadgetview',
store: store,
columns: [{
header: 'ID',
text: 'ID',
dataIndex: 'id',
width: 50
}],
height: 200,
width: 450,
title: 'Example'
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.