PDA

View Full Version : How to refresh a combobox's data without triggering



jd_porter
1 May 2007, 11:17 AM
I have a combobox with an HTTPProxy data store as :


store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: xmlTemplateNames, method: 'get'}),
reader: new Ext.data.XmlReader({record: 'row'},
['rownum','template_id','title'])
});
cbo = new Ext.form.ComboBox ({
store: store,
displayField: 'title',
valueField: 'template_id',
mode: 'remote',
triggerAction: 'all',
emptyText: 'Select Template'
});

It's possible for the data behind the store to be updated by other users, and I'd like to refresh the combobox's every once in a while. I don't see anything in the combobox's documentation that'll do this, so I figured I could use
cbo.store.reload() to the same effect. However, when I do this, the combobox's onTrigger event happens. I think there's an event somewhere I might need to unregister to prevent the combobox from triggering, but I'm not sure what it is.
Thanks for your help.

jsakalos
1 May 2007, 12:35 PM
I don't think you need anything else as to (re)load combo's store.

jd_porter
1 May 2007, 1:06 PM
I don't think you need anything else as to (re)load combo's store.
That much I get. The problem is that when I do reload the store, the combo's dropdown list appears. I want to reload without having the list appear.

tryanDLS
1 May 2007, 1:34 PM
I don't see a way to this with the current codebase. You could override the onLoad method to do something different. The quick and dirty way would be to set hasFocus=false to short circuit the entire method, you'd have experiment to see if bypassing the rest of that causes you a problem. Both the method and the property are private, so this wouldn't be a long-term solution, but maybe somebody else has other thoughts.

jsakalos
1 May 2007, 3:39 PM
Hmmm,

I have done it somehow... ;)

I have combo with HttpProxy, JsonReader but I have set mode:local. This way the combo is not reloaded when user clicks the trigger but the list doesn't appear when I reload the combo programmatically.



var ds = new Ext.data.Store({
baseParams: {
requestID: 'getData'
, objName: 'orgbList'
, format: 'json'
}
, proxy: new Ext.data.HttpProxy({method:'post', url:'/ajax.php'})
, reader: new Ext.data.JsonReader({
root: 'records'
, totalProperty: 'totalCount'
, id: 'orgbID'
}, [{name:'orgbID'}, {name:'orgbName'}, {name:'orgbDesc'}])
});
var combo = new Ext.form.ComboBox({
store: ds
, triggerAction: 'all'
// this is because i wanna control when to load (new) data
// from server by combo.store.load()
, mode: 'local'
, forceSelection: true
, editable: false
, valueField: 'orgbID'
, displayField: 'orgbName'
, width: 240
, tpl: '<div class="x-combo-list-item"><div><b>{orgbName}</b></div>' +
'<i style="font-size:smaller;">{orgbDesc}</i></div>'
, listeners: {select:{
fn: function(combo, record, index) {
orgbID = record.data.orgbID;
orgbName = record.data.orgbName;
headContent.update(orgbName);
Ext.state.Manager.set("orgbID", orgbID);
}
}}
});
This is my unabbreviated combo config so take from it only what pertains to your app.

jd_porter
1 May 2007, 6:50 PM
Hmmm,

I have done it somehow... ;)

I have combo with HttpProxy, JsonReader but I have set mode:local. This way the combo is not reloaded when user clicks the trigger but the list doesn't appear when I reload the combo programmatically.
This is my unabbreviated combo config so take from it only what pertains to your app.

Setting the mode to 'local' solved my problem. Thanks a bunch!

jsakalos
2 May 2007, 1:41 AM
I'm glad I helped.