Wah*_*hmy 5 event-handling extjs4
我是EXTJS 4和这个论坛的新手.对不起,如果它已在另一个线程中讨论过,但我没有找到它.
我的问题是,我希望我的Grid Panel with Pagination每10秒更新一次它的商店.我找到了一个使用的解决方案userStore.loadPage(current_page)
,但它有一个问题.
有一段时间,几乎在同一时间更新Grid Panel,用户点击分页中的"next"或"prev".这使Grid Panel无法正常工作.我想要的是,当我点击"下一步"或"上一步"或"刷新"时,前一个请求(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
}]
});
Run Code Online (Sandbox Code Playgroud)
它是每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);
}
}
Run Code Online (Sandbox Code Playgroud)
您可以查看有关分页工具栏组件的文档: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.toolbar.Paging
change
每次当前页面更改时都会触发一个,因此它将在“下一个”和“上一个”点击事件时触发。我没有尝试过,但我认为它也可能因“刷新”而被解雇。
disable()
在我看来,最好的设计是在自动重新加载加载时禁用分页工具栏的按钮(使用该组件的功能)。