PDA

View Full Version : How To Access Grid ComboBox Store To Load



sportda
16 Oct 2010, 10:49 AM
In my grid I have combo box that is dynamically filled with data and works properly..



var owners_store = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields:['owner_id','owner_name'],
root:'owners'
}),
proxy: new Ext.data.HttpProxy({
url: 'load_owners.php'
})
});

var ownersCombo = new Ext.form.ComboBox({
store: owners_store,
displayField: 'owner_name',
valueField: 'owner_id',
hiddenName:'owner_name',
typeAhead: false,
triggerAction: 'all',
editable: false,
anchor: '55%',
allowBlank: false,
autoLoad: true,
mode: 'remote'
});
I need to load the store so the values can be displayed instead of the ids before the combo is activated. I have a function that is a member of my grid object that gets called at the appropriate time but I cannot figure out how to access the store of the combo and get it to load in the function...



loadOwnerStore: function()
{
combo = this.getColumnModel().getCellEditor(1,0);
combo.getStore().load();
},
The above code is obviously incorrect but hopefully it is good enough pseudo code to show what I'm trying to do. Can anyone teach me the correct way to do this?

sportda
16 Oct 2010, 1:20 PM
I moved the owners_store variable out of the grid object into the global scope, which I would have preferred not to have to do, and I can now access it in my function like this...



loadOwnerStore: function() {
owners_store.reload(); // Not at all sure this is the right function to call!
},


But this doesn't get the text values displayed in the grid combo box, the ids are still displayed until I drop down the combo box and then sort the column.

mcadirci
17 Oct 2010, 1:26 AM
Hello,

If you wanna handle smt on store load you need to add listener

store.on('load', onStoreLoad);

If you need to access an Ext item any where you could use:

var ownersCombo = new Ext.form.ComboBox({
id: 'comboboId',
store: owners_store,
displayField: 'owner_name',
valueField: 'owner_id',
hiddenName:'owner_name',
typeAhead: false,
triggerAction: 'all',
editable: false,
anchor: '55%',
allowBlank: false,
autoLoad: true,
mode: 'remote'
});
....
Ext.getCmp('comboboxId').setValue('smt');

--
Mehmet

Animal
17 Oct 2010, 2:07 AM
Why not just autoLoad the Store, and have the ComboBox mode: 'local'? It's simple.