Javascript can';t将json数据加载到网格extjs中
我尝试了我找到的每一个答案(在Stackoverflow中有很多)来解决我在extjs存储中的问题,但是数据仍然没有显示在网格中,即使网格正确播放。我很困惑,所以我写的“商店”我能够建立阅读答案在这个网站上。我不知道为什么它不把数据加载到网格中。如果您需要更多信息来帮助,请询问Javascript can';t将json数据加载到网格extjs中,javascript,json,grid,extjs4,store,Javascript,Json,Grid,Extjs4,Store,我尝试了我找到的每一个答案(在Stackoverflow中有很多)来解决我在extjs存储中的问题,但是数据仍然没有显示在网格中,即使网格正确播放。我很困惑,所以我写的“商店”我能够建立阅读答案在这个网站上。我不知道为什么它不把数据加载到网格中。如果您需要更多信息来帮助,请询问 store: Ext.create('Ext.data.Store', { autoLoad: true, storeId: 'StoreName', fields: ['id','name'],
store: Ext.create('Ext.data.Store', {
autoLoad: true,
storeId: 'StoreName',
fields: ['id','name'],
data : JsonObject,
model: 'ModelName',
proxy: {
type: 'memory',
reader: {
type: 'json',
record: 'JsonRoot'
}
}
})
网格通过ajax调用加载到新窗口中。新窗口的代码如下所示:
Ext.create('Ext.window.Window', {
title: 'GridTitle',
height: 200,
width: 400,
layout: 'fit',
items: {
xtype: 'grid',
border: false,
columns: [
{
text : 'id',
flex : 1,
sortable : true,
dataIndex: 'id'
},
{
text : 'name',
width : 300,
sortable : true,
dataIndex: 'name'
}],
我的印象是,ext.js没有读取带有列的部分,因为它没有索引我在json中传递给它的数据的名称和id。解决方案非常简单,我很难说出来
reader: {
type: 'json',
root: 'jsonRoot'
}
而不是:
reader: {
type: 'json',
record: 'jsonRoot'
}
您正在以Json的形式提供数据。为什么不尝试使用-type:“ajax”并向存储区提供URL,因为网格已经进入ajax调用,json是该调用的响应文本。所以我不需要再调用json,它已经存在了,可以用作“内存”。它没有任何异常,所以我认为它是正确的。