我无法动态更新商店,也看不到商店中反映的那些更新。我正在尝试向商店添加一条记录,只是看到商店反映了更新。这是控制器方法:
testGridrefresh() {
console.log("start testGridrefresh");
const testmodel = new MyCustomer.model.Testmodel({ // Testmodel is the model used by my store
firstName: 'joe',
lastName: 'whatever'
});
console.log(testmodel); // logs correctly, i can see the fields
store = this.getStore('tests');
console.log("count in store:");
console.log(store.getTotalCount()); // i hard coded 2 items, prints 2
store.add(testmodel);
store.commitChanges();
store.sync();
store.reload();
console.log("lets see what the count in store is now");
console.log(store.getTotalCount()); // still logs 2
// try different approach:
var new_data = {
'newrecord': {
"firstName": 'joe',
"lastName": 'whatever'
}
};
store.add(new_data);
store.commitChanges();
store.sync();
store.reload();
console.log("lets see what the count in store is now");
console.log(store.getTotalCount()); // still logs 2
}