Extjs 分页工具条加按钮,然后输入第几页,点击按钮就跳转到第几页怎么实现?
展开全部
给那个数据框添加侦听事件,点击或者回车时执行侦听事件,执行数据加载就可以了。我的源码:
var pagingBar = new Ext.PagingToolbar({
pageSize : Cookies.get('pageSize')
? parseInt(Cookies.get('pageSize'))
: 15,
store : myStore,
displayInfo : true,
displayMsg : '第{0} - {1}条,共{2}条',
emptyMsg : "没有记录",
items : ['-', '每页', new Ext.form.Field({
hideLabel : 'true',
size : '3',
height : '18',
cls : "x-tbar-page-number",
id : 'pagefield'
}), '条记录']
});
if (Ext.getCmp('pagefield')) {
Ext.getCmp('pagefield').on("specialkey", function(arg, e) {
var k = e.getKey();
if (k == e.RETURN) {
e.stopEvent();
pagingBar.pageSize = parseInt((arg.getValue()%1==0 && arg.getValue()>0)?arg.getValue():15);
Cookies.set('pageSize', pagingBar.pageSize);
pagingBar.doLoad(0);
arg.setValue(pagingBar.pageSize);
} else if (k == e.UP || k == e.PAGEUP || k == e.DOWN
|| k == e.PAGEDOWN) {
e.stopEvent();
var pageNum = parseInt((arg.getValue()%1==0 && arg.getValue()>0)?arg.getValue():15);
var increment = e.shiftKey ? 10 : 1;
if (k == e.DOWN || k == e.PAGEDOWN) {
increment *= -1;
}
pageNum += increment;
arg.setValue(pageNum);
}
});
Ext.getCmp('pagefield').on("focus", function() {
this.el.dom.select();
});
Ext.getCmp('pagefield').setValue(pagingBar.pageSize);
}
var pagingBar = new Ext.PagingToolbar({
pageSize : Cookies.get('pageSize')
? parseInt(Cookies.get('pageSize'))
: 15,
store : myStore,
displayInfo : true,
displayMsg : '第{0} - {1}条,共{2}条',
emptyMsg : "没有记录",
items : ['-', '每页', new Ext.form.Field({
hideLabel : 'true',
size : '3',
height : '18',
cls : "x-tbar-page-number",
id : 'pagefield'
}), '条记录']
});
if (Ext.getCmp('pagefield')) {
Ext.getCmp('pagefield').on("specialkey", function(arg, e) {
var k = e.getKey();
if (k == e.RETURN) {
e.stopEvent();
pagingBar.pageSize = parseInt((arg.getValue()%1==0 && arg.getValue()>0)?arg.getValue():15);
Cookies.set('pageSize', pagingBar.pageSize);
pagingBar.doLoad(0);
arg.setValue(pagingBar.pageSize);
} else if (k == e.UP || k == e.PAGEUP || k == e.DOWN
|| k == e.PAGEDOWN) {
e.stopEvent();
var pageNum = parseInt((arg.getValue()%1==0 && arg.getValue()>0)?arg.getValue():15);
var increment = e.shiftKey ? 10 : 1;
if (k == e.DOWN || k == e.PAGEDOWN) {
increment *= -1;
}
pageNum += increment;
arg.setValue(pageNum);
}
});
Ext.getCmp('pagefield').on("focus", function() {
this.el.dom.select();
});
Ext.getCmp('pagefield').setValue(pagingBar.pageSize);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询