fractorr
16 Jul 2007, 10:01 AM
I came up with this to be able to change the number of records per page in a grid. Not sure if this is the best method to do it but it works.
var gridFoot = grid.getView().getFooterPanel(true);
// add a paging toolbar to the grid's footer
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 25,
displayInfo: true,
displayMsg: 'Displaying {0} - {1} of {2}',
emptyMsg: "No information to display"
});
PerPageData = [
['10', '10'],
['25', '25'],
['50', '50'],
['100', '100'],
['0', 'ALL']
];
var ppstore = new Ext.data.SimpleStore({
fields: ['num', 'txt'],
data : PerPageData
});
var perPage = new Ext.form.ComboBox({
store: ppstore,
displayField:'txt',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
selectOnFocus:true,
resizable:true,
listWidth: 50,
width: 50,
value: '25'
});
function setPerPage()
{
if (perPage.getValue() != 'ALL')
{
paging.pageSize = parseInt(perPage.getValue());
}
else
{
paging.pageSize = ds.getTotalCount();
}
paging.cursor = 0;
ds.load({params:{start: paging.cursor, limit: paging.pageSize}});
}
perPage.on("select", setPerPage);
paging.addSeparator();
paging.addText("Per Page");
paging.addField(perPage);
var gridFoot = grid.getView().getFooterPanel(true);
// add a paging toolbar to the grid's footer
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 25,
displayInfo: true,
displayMsg: 'Displaying {0} - {1} of {2}',
emptyMsg: "No information to display"
});
PerPageData = [
['10', '10'],
['25', '25'],
['50', '50'],
['100', '100'],
['0', 'ALL']
];
var ppstore = new Ext.data.SimpleStore({
fields: ['num', 'txt'],
data : PerPageData
});
var perPage = new Ext.form.ComboBox({
store: ppstore,
displayField:'txt',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
selectOnFocus:true,
resizable:true,
listWidth: 50,
width: 50,
value: '25'
});
function setPerPage()
{
if (perPage.getValue() != 'ALL')
{
paging.pageSize = parseInt(perPage.getValue());
}
else
{
paging.pageSize = ds.getTotalCount();
}
paging.cursor = 0;
ds.load({params:{start: paging.cursor, limit: paging.pageSize}});
}
perPage.on("select", setPerPage);
paging.addSeparator();
paging.addText("Per Page");
paging.addField(perPage);