View Full Version : Set initial selection value/name on combo with pagination

11 Sep 2008, 11:35 PM
Is there any other way to set the initial value/name other than this e.g.:

new Ext.data.Record(

I tried with setValue and setRawValue with no success.

What I know is that setValue() search the combo store for a record with an ID matching the value ID, if it finds one, it puts the display name configured in the combo, based on the record. If not, it puts just the ID as the display value.

Other way to do it is:


THe last method is not consistent with a paginated store.

I would like to know how it really works and why there's no method like:

Any Ideas ?

12 Sep 2008, 12:08 AM
you can see http://extjs.com/forum/showthread.php?t=12603
it may be help:)

12 Sep 2008, 7:04 AM
The problem is kind of a chicken before the egg thing; in order to select an item in the combobox, it must already have the list (store) loaded. the right way to do it is to have the combo intelligently look for a match after the store loads, similar to your second example. I have attempted to do this with my improved remote comboBox override, so it may work for your needs.

12 Sep 2008, 11:44 AM
The second method I mentioned works nice but is not reliable with the combo pagination feature. no pagination and works perfect.

Let's say I get the first 10 records from the database with pagination (start:0,limit:10). Now the store/combo has those first 10 records. But what if I want to set the initial value with the record 11 ?
In that case, I can't get the value/name pair from the already loaded store. I have to add manually the name/pair to the store.

At the end the store ends up with 11 records. 10 loaded from the initial pagination load, and the 11th added manually.

A temporal solution for this was:

Ext.form.ComboBox.prototype.initialPair = function(id,name){
temp = {};
temp[this.valueField] = id;
temp[this.displayField] = name;

new Ext.data.Record(temp)


I wonder if there's an existing and better way for doing this.

ldsophia, the link you recommend is nice, but does not deal with pagination. Thanks anyway.