【发布时间】:2011-10-18 09:58:23
【问题描述】:
我是 EXTJS 4 和这个论坛的新手。对不起,如果它已经在另一个帖子中讨论过,但我没有找到它。
我的问题是,我希望我的分页网格面板每 10 秒更新一次它的存储。我找到了使用userStore.loadPage(current_page) 的解决方案,但它有一个问题。
有时,用户在分页中单击“下一个”或“上一个”几乎同时更新网格面板。这使网格面板无法正常工作。我想要的是,当我单击“下一个”或“上一个”或“刷新”时,上一个请求(userStore.loadPage(current_page))被中止。所以它不会干扰我当前的请求。
但我没有在 EXTJS 分页工具栏中找到处理“下一个”、“上一个”或“刷新”按钮的事件。这个问题的解决方案是什么?有什么办法吗?
这是我的代码仅供参考:
// create User Store
var userStore = Ext.create('Ext.data.Store', {
model: 'EDC',
autoLoad: true,
pageSize: 10,
proxy: {
type: 'ajax',
url : 'Monitoring', // it is using Java servlet, so I write it this way
reader: {
type: 'json',
root: 'edc',
totalProperty: 'total'
}
}
});
// create Grid Panel
Ext.create('Ext.grid.Panel', {
store: userStore,
width: 800,
height: 400,
columns: [
{
text: "ID",
width: 50,
dataIndex: 'id'
},
{
text: 'Serial Number',
flex: 1,
dataIndex: 'sn'
}
// etc...
],
dockedItems: [{
xtype: 'pagingtoolbar',
store: userStore,
dock: 'bottom',
displayInfo: true
}]
});
每10秒更新一次
// after on Ready, reload every 10 seconds
Ext.onReady(function(){
self.setInterval("reloadCurrentEdc()", 10000);
});
// function for update
function reloadCurrentEdc(){
if(typeof userStore != 'undefined'){
userStore.loadPage(userStore.currentPage);
}
}
【问题讨论】:
标签: event-handling extjs4