PDA

View Full Version : how to load data for this case?



theo
27 Nov 2007, 12:20 AM
when we create a combo box , we need a store.load().but this means the data is loaded before combo box created.

I want to this: when I click the combo box ,then load data. but combobox seems has no click events. how to do it?

tellioglu
27 Nov 2007, 12:36 AM
There are many events listed in the documentation of the combobox. And there is even a function called onTriggerClick() ;) But maybe I don't understand your problem...

theo
27 Nov 2007, 1:07 AM
There are many events listed in the documentation of the combobox. And there is even a function called onTriggerClick() ;) But maybe I don't understand your problem...
ok, my code is:

store = Core.data.Store.create({
id : 'status',
url : 'codelist_list_json.action?book=status',
fields : [{name: 'id'}, {name: 'name'}]
});
store.getStore().load();
}

var combo = Core.form.ComboBox.create({
id : 'status',
store : store,
displayField: 'name',
valueField: 'id'
});
also the mode is "local", I don't want the combo box load the data before I click it. the ontriggerClick seems no useful.

theo
27 Nov 2007, 1:56 AM
OK! solved !
overwrite ontriggerclick() is right.

Ext.form.ComboBox.prototype.onTriggerClick = function(){
if(this.disabled){
return;
}
if(this.isExpanded()){
this.collapse();
this.el.focus();
}else {
this.onFocus({});
if(this.triggerAction == 'all') {
this.doQuery(this.allQuery, true);
} else {
this.doQuery(this.getRawValue());
}
this.el.focus();
}
this.store.load();
};