无法使用 loadData() 在 ExtJS gridpanel 中加载数据
我需要定期在网格存储中添加新数据。该存储由以下代码定义:
this.reader = new Ext.data.JsonReader({
idProperty: 'id',
fields: this.lesFields
});
this.ds = new Ext.data.GroupingStore({
reader: this.reader,
data: this.leData,
sortInfo: {field: 'dendisc', direction: 'ASC'},
groupField: 'categorie'
});
当我需要附加一些新数据时,我使用 this.getStore().loadData(this.leData)
来执行此操作。从技术上讲,数据确实出现在网格的存储中,但我在显示屏上只看到零(在 int
字段中)和空白字符串(在 string
字段中)。我在 Chrome 的控制台中做了一些研究,发现 this.getStore().datadata
属性和 json
属性不一样代码>.在 json
中存在包含有效数据的数组,但在 data
中只有零和空白字符串。
我错过了什么吗? handleAs:'json'
属性会保存这种情况吗?
I need to periodically add new data in the grid's store. The store is defined by the following code:
this.reader = new Ext.data.JsonReader({
idProperty: 'id',
fields: this.lesFields
});
this.ds = new Ext.data.GroupingStore({
reader: this.reader,
data: this.leData,
sortInfo: {field: 'dendisc', direction: 'ASC'},
groupField: 'categorie'
});
When I need to append some new data, I do this using this.getStore().loadData(this.leData)
. Technically the data does appear in the grid's store, but I see on the display only zeros (in the int
fields) and blank strings (in the string
fields). I did some researches in Chrome's console and I found out that the data
property and the json
property are not the same in this.getStore().data
. In json
there is the array with valid data, but in data
there are only zeros and blank strings.
Am I missing something? Would the handleAs:'json'
property save the situation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JsonReader 需要定义 root。 root 指向包含记录的子属性。
这里是从 ext 文档中获取的示例:
以及要读取的示例数据:
JsonReader requires root to be defined. root points the sub-property which contains the records.
here a sample taken from ext documentation:
and a sample data to be read:
我不太习惯 GroupingStores,但我认为读者期望像
{ Id:0, Name: 'MyName' }
这样的 json 对象或此类对象的数组,然后尝试将它们与注册的进行匹配字段名称。但我不知道你的数组中有什么所以这只是一个猜测I am not that used to GroupingStores but I think the Reader expect a json object like
{ Id:0, Name: 'MyName' }
or a Array of such objects and then try to match them against the registered fieldnames. But I don't know what there is in your arrays so this is just a guess