ExtJs 4.x 学习小记:Ext.PagingToolbar的使用

在使用Grid显示数据列表时,为了查看方便,经常用到的是分页显示,Ext中使用Ext.PagingToolbar来实现,这里只做基本应用介绍,Ext.PagingToolbar的详细配置项及属性可以查阅ExtJs 4.x的API文档http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.toolbar.Paging,实现后具体界面如下


定义每页显示数量

var countPerPage = 5;

定义store(reader要包含在proxy里面,否则无法起作用)

 var store = Ext.create('Ext.data.Store', {
 		baseParams:{catalogid:0},
 		pageSize:countPerPage,
		fields: ["id","filecode","filename"],
		proxy: {
            type: 'ajax',
            url: '././FileListServlet',
            reader:{
        	type:'json',
        	root:'items',
        	totalProperty:'total'
        	}
        }          
    });

Grid定义

 var fileGridPanel = Ext.create('Ext.grid.Panel',{
 	id:'filegrid',
 	layout:'fit',
 	store:store,
 	loadMask:false,
 	autoExpandColumn:true,
 	columns:[
 		{text:'编号',dataIndex:'filecode',width:80},
 		{text:'文件名',dataIndex:'filename',flex:1},
 		{xtype:'actioncolumn',width:50,
 			items:[{
 			icon:'././image/del.png',
 			tooltip:'删除',
 			handler: function(grid, rowIndex, colIndex) {
                    
                    Ext.Msg.confirm("警告", "确定要删除吗?", function(button) {  
                            if (button == "yes") 
                            {  
                            	var rec = grid.getStore().getAt(rowIndex);  
                            	Ext.Ajax.request({
                            		url:'././DeleteRecordByID',
                            		params:{
                            			tablename:'filedata',
                            			id:rec.get('id')
                            		},
                            		method:'post',
                            		success:function(response,opts)
                            		{
                            			grid.getStore().remove(rec); 
                            		}
                            	})                                
                            }  
                        }); 
                }
 			},
 			{
 			icon:'././image/view.png',
 			tooltip:'预览'
 			}]
 		}
 		],
 	dockedItems:[{
 		xtype:'toolbar',
 		dock:'top',
 		items:[searchbar]
 	},{
 		xtype:'toolbar',
 		dock:'top', 		
 		items:[funcbar]}],
 	bbar:Ext.create('Ext.PagingToolbar',{
 		store:store,
 		displayInfo:true,
 		displayMsg:'显示{0}-{1}条,共{2}条',
 		emptyMsg:'无数据'
 	})
 });


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bdmh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值