我的问题非常像this one,但它有一个问题,因为必须在新窗口中加载JSON。像this这样的东西。正如您所看到的,商店在新窗口的ITEMS中有一个位置。
就是这样,我无法总结两个解决方案,一个用于读取JSON,一个用于在新窗口中创建网格,以创建一个可以读取我传递给新窗口的json的网格。如何在第二个示例(或下面的示例中)中设计商店行,使其读取包含所有JSON数据的变量,并且已经记录并准备好使用?
var obj = response;
try {
obj = Ext.decode(response.responseText);
} catch (error) {}
if (obj) {
Ext.create('Ext.window.Window', {
title: 'Hello',
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'
}],
store: Ext.create('Ext.data.ArrayStore', {}) //this is the line I have to change
}
}).show();
} else {
alert("Invalid response")
}
答案 0 :(得分:0)
工作,但仍然没有完全加载json数据导致数据没有root。这是我目前找到的答案。
Ext.create('Ext.window.Window', {
title: 'Admants',
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'
}],
store: Ext.create('Ext.data.Store', {
storeId: 'My Grid',
fields: ['id', 'name'],
data: obj,
proxy: {
type: 'memory',
reader: {
type: 'json',
record: ""
}
}
})
}}).show();
这部分解决了。