1
我有一个简单的网格,它看起来像这样:商店添加 - 不工作
{
xtype: "grid",
columns: [{
header: 'Title', flex: 1, dataIndex: 'Title'
}],
store: Ext.create('Ext.data.Store', {
fields:['id', 'Title']
})
}
而且我有一个功能(连接到一个按钮)的,我认为,应该填充该网格的一些数据。它做它像这样:
grid.store.removeAll();
records = [{"id":"1", "Title", "Hello world"}];
grid.store.add(records);
grid.store.load();
console.log(grid.store.getCount());
但由于某些原因,疯狂,商店是空的,grid.store.getCount()
呼应“0”。到底他妈发生了什么? PS。我使用ExtJS的6
编辑
然而,如果我稍微我的代码改成这样:
...
store: Ext.create('Ext.data.Store', {
autoLoad: false,
fields:['id','Title'],
data:[{"id": 1,"Title": "Hello world"}]
})
...
//and in function just one line of code:
grid.store.load();
然后开始工作。所以,整个问题似乎是store.add
。它没有做它应该做的。
哦,谢谢你,先生!你为我的一天保存了一百次。 – Jacobian