PDA

View Full Version : pageSize on Combobox for remote loading



murrah
1 Aug 2012, 8:23 PM
Hi.

It seems that to set the pageSize on a Combobox for remote loading you need to put the pageSize config option on the store as well as the Combobox.

Ext.define('AM.view.user.ComboRemote', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.usercomboremote',
queryMode: 'remote',
fieldLabel: 'Search by name',
width: 320,
forceFieldSelection: true,
displayField: 'name',
valueField: 'id',

pageSize: 3, // has no effect on paging toolbar apart from making it appear

minChars: 1,
triggerAction: 'all',
store: 'ComboRemote'
});

Ext.define('AM.store.ComboRemote', {
// extend: 'Ext.data.JsonStore', // Using the JsonStore results in "url undefined" message
extend: 'Ext.data.Store',
alias: 'widget.comboremotestore',
storeId: 'people',
fields: ['name'],

pageSize: 3, // This is what actually controls the calculations for page size

proxy: {
type: 'ajax',
url: 'http://somedomain.com/users',
reader: {
type: 'json',
root: 'users',
totalProperty: 'total'
}
}
});

And note that if your returned JSON has more records than the pageSize, they will ALL be displayed in the list. ie it is up to you to restrict the number of records returned to the pageSize value which is passed to the server as the "limit" parameter (along with "start" and "page") so you can decide which records to return.

Note the comment about which store to use. I, and others, have experienced that if you use a JsonStore, the url parameter does not end up on the store object, resulting in an error (url is undefined). Changing to an Ext.data.Store makes this problem go away.

FYI.

Murray