View Full Version : create temporary store, use it to fill combobox

20 Nov 2012, 10:01 PM
In previous work I've been able to dynamically declare a temporary store and use it to fill a grid, and I've forced a combobox to preload it's options... But now that i'm trying to combine the two I'm having trouble getting it to work

var store = Ext.create('Ext.data.Store', {fields:[
{name:'name'}, {name:'Id'}



for (var count=0; count<data.length; count++)

I Checked that box is a component, and it alerts '2' so i know the store is being populated, but for some reason it's not triggering the combobox to update

21 Nov 2012, 7:11 AM
Show us the configuration of your combobox!:-?

21 Nov 2012, 7:52 AM
as far as i know you have to trigger the load event and only that updates the combobox

21 Nov 2012, 2:28 PM
Here ya go chramer:

{ xtype: 'combobox',
flex: 1.5,
itemId: 'cat1',
name: 'cat1',
value: 'All',
fieldLabel: 'Category',
labelWidth: 75,
displayField: 'name',
valueField: 'Id'

eladc, i've made it work that way with other comboboxes too, but there's a hiccup this time, take a look at the documentation for load():

load (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-method-load)( [options] )7 - Loads data into the Store via the configured proxy (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-cfg-proxy).
And it doesn't take long to compare to my store:

Ext.create('Ext.data.Store', { fields:[{name:'name'},{name:'Id'}] });
No proxy.

23 Nov 2012, 1:14 PM
I have exactly the same problem

I want to fill an array with the results of calculations and then the data are in the combobox
just like?

25 Nov 2012, 7:45 PM
I got it working... after eventually checking what i had, and my new cleaned up code the only difference i could find was right after the loop i called box.show()... Hope that's all and it works for anyone else who finds this thread.

WAIT! - No i remember why it was now!... You need to call Load() if the combobox if the queryMode is remote! so if your combobox's querymode is set to remote (and by default it is) it expects the data only exists when it it retrieved from the server (so only refreshes when you load) but an array you make in memory? That's Local! set your querymode to Local and the code should probably run fine. It seems like it should be unimportant, but that one config changes a lot of the behind the scenes behavior, so make sure you pick correctly.

DetBerlin - One last thing, probably obvious but make sure the array of calculations you generate is in the same format as the store you are going to dump it in, and your combobox's DisplayField and ValueField also match up to those names. For instance in mine i had a name and an id, so an array with 3 items would be

{"name":"a", "id":1},
{"name":"b", "id":2},
{"name":"c", "id":3}


var data = new Array();
data[0] = {"name":"a", "id":1};
data[1] = {"name":"b", "id":2};

var entry = new Object();

data[2]= entry;

Good luck!