PDA

View Full Version : autoLoad ComboBox from remote store? How?



bbxx
15 Oct 2009, 6:11 PM
I am trying to get my combo to load it's options from the remote store automatically, but it's not. It only loads the values when I select the drop down.


{
xtype: 'combo',
name: 'formula-feed',
fieldLabel: 'Feed',
valueField: 'ID',
displayField: 'FeedName',
triggerAction: 'all',
emptyText:'Select a feed...',
selectOnFocus:true,
mode: 'remote',
triggerAction: 'all',
autoLoad: true,
store: {
xtype: 'store',
autoLoad: true,
proxy: new Ext.data.HttpProxy({
url: 'AppTasks.php', // File to connect to
method: 'POST'
}),
baseParams:{task: "GET_FEED_LIST"}, // this parameter asks for listing
reader: new Ext.data.JsonReader({
// we tell the datastore where to get his data from
root: 'results',
id: 'ID'
},[
{name: 'ID', type: 'int', mapping: 'ID'},
{name: 'FeedName', type: 'string', mapping: 'FeedName'}
]),
sortInfo:{field: 'FeedName', direction: "ASC"}

}
}

teddyjas
15 Oct 2009, 7:01 PM
have u try the lazyInit: false ?

bbxx
15 Oct 2009, 7:36 PM
have u try the lazyInit: false ?

Thanks for the suggestion. I just tried that, but it doesn't work:(

teddyjas
15 Oct 2009, 10:41 PM
heh? by rite that should do... r u sure u not misplacing the config?

bbxx
15 Oct 2009, 11:07 PM
heh? by rite that should do... r u sure u not misplacing the config?


Here's where I put it:


{
xtype: 'combo',
name: 'formula-feed',
fieldLabel: 'Feed',
valueField: 'ID',
displayField: 'FeedName',
triggerAction: 'all',
emptyText:'Select a feed...',
selectOnFocus:true,
mode: 'remote',
forceSelection : true,
lazyInit: false,
store: {
xtype: 'store',
autoLoad: true,
proxy: new Ext.data.HttpProxy({
url: 'AppTasks.php', // File to connect to
method: 'POST'
}),
baseParams:{task: "GET_FEED_LIST"}, // this parameter asks for listing
reader: new Ext.data.JsonReader({
// we tell the datastore where to get his data from
root: 'results',
id: 'ID'
},[
{name: 'ID', type: 'int', mapping: 'ID'},
{name: 'FeedName', type: 'string', mapping: 'FeedName'}
]),
sortInfo:{field: 'FeedName', direction: "ASC"}

}
}

bbxx
16 Oct 2009, 9:43 AM
I'm still struggling to figure this out... I added a listener to the form itself, to try to load the combobox when the form renders:



listeners: {
'render': function(form, action){
//if (action.type=='load')
//alert('render');
this.getForm().findField('formula-feed').store.load();
},


I can see from firebug that the store does pull the data, but the combo box doesn't seem to pick it up. When I select the combobox it says "loading..." and then pulls the data from the server again. Anyone?

Mike Robinson
16 Oct 2009, 2:34 PM
"mode = 'remote'," I believe, is what you are looking for. (versus "local.")

bbxx
16 Oct 2009, 3:48 PM
"mode = 'remote'," I believe, is what you are looking for. (versus "local.")

No, it is already set to remote.

Spirit
20 Oct 2009, 3:03 AM
You have to set it to "local", so that it will be loaded when page gets viewed. If you set it remote it will be loaded on selction.