日期:2014-05-16  浏览次数:20276 次

Extjs grid pageSize 让用户自己决定

今天在问题模块给别回答问题的时候,为了解决别人的问题,我写下了这篇文章

?

也没什么高深的技术,就是在网上看到了别人写的代码,自己感觉非常不错,这里也有了点灵感,所以写了这篇文章

?

希望对那个有问题的人有帮助

?

?

var combo = new Ext.form.ComboBox({
	name : 'perpage',
	width: 40,
	store: new Ext.data.ArrayStore({
	fields: ['id'],
	data  : [
		['15'],
		['25'],
		['50']
		]
	}),

	mode : 'local',
	value: '15',
	listWidth     : 40,
	triggerAction : 'all',
	displayField  : 'id',
	valueField    : 'id',
	editable      : false,
	forceSelection: true
});

var bbar = new Ext.PagingToolbar({
	store:       store, //the store you use in your grid
	displayInfo: true,
	items   :    [
		'-',
		'Per Page: ',
		combo
	]
});
combo.on('select', function(combo, record) {
	bbar.pageSize = parseInt(record.get('id'), 10);
	bbar.doLoad(bbar.cursor);
}, this);

var grid = new Ext.grid.GridPanel({
	//your grid setup here...
	bbar: bbar
});

?

代码没有调试,不过大体思路,我想大家一看就明白,然后将问题解决。。。