我通过获取其id来删除网格中的一行,并调用rest web服务将其从数据库中删除。通过调用store.load()来更新数据网格;问题是记录计数永远不会改变,除非我刷新页面。
success : function (response) {
console.log("count before load" + pDetailsTab.tvsListGrid.store.getCount());
pDetailsTab.tvsListGrid.store.load();
console.log("count after load " + pDetailsTab.tvsListGrid.store.getCount());
if (pDetailsTab.tvsListGrid.store.getCount() >= 1) {
console.log("inside if");
pDetailsTab.tvsListGrid.getSelectionModel().select(0);
} else if (pDetailsTab.respSGrid.store.getCount() >= 1) {
pDetailsTab.respSGrid.getSelectionModel().select(0);
}
ExtjsUtils.hideWait();
}下面是console.log的输出(我用‘...’替换了一些输出):
count before reload 1 ...
...
count after reload 1 ...我在网上找过了,但一无所获。有什么想法吗?
发布于 2014-02-22 05:14:13
问题是load()是异步的。此代码必须如下所示:
pDetailsTab.tvsListGrid.store.load({
scope: this,
callback : function(records, operation, success) {
console.log("count after load " + pDetailsTab.tvsListGrid.store.getCount());
if (pDetailsTab.tvsListGrid.store.getCount() >= 1) {
console.log("inside if");
pDetailsTab.tvsListGrid.getSelectionModel().select(0);
} else if (pDetailsTab.respSGrid.store.getCount() >= 1) {
pDetailsTab.respSGrid.getSelectionModel().select(0);
}
ExtjsUtils.hideWait();
});请查看4.1.3版http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.data.Store-method-load的exjts文档
发布于 2014-02-19 22:26:41
使用网格的grid.getView().refresh()方法或通过grid.getStore().reload()重新加载网格的存储
发布于 2014-02-20 17:33:23
您是否从服务器获得了正确的记录计数?尝试调试java代码并查看查询结果。这可能是返回记录的java代码的问题。
https://stackoverflow.com/questions/21882843
复制相似问题