PDA

View Full Version : Reloading combobox data after any key pressed



dende1979
14 Sep 2007, 4:59 AM
Hello,
I have an autocompleting combo which load/reload Its datastore calling a remote service.
This works fine but datastore is reloaded only after typing something into the combo and pressing the key-down or the downarrow on the right (in other words only after 'expand' event is fired).
I want to load/reload data store (and to show it by expanding the combo) after typing any character into the combo, too:

1. select the combo
2. type a character
3. reload combo's datastore
4. expand combo and show updated datastore
...

In other words how can I assign the 'keypressed' event to the combobox?

Thanks a lot.

Here my javascript code for my combo



Ext.onReady(function(){
var doctorStore = new Ext.data.Store (
{
proxy: new Ext.data.HttpProxy (
{
url: "searchdoctorflex.do?"
}
),
reader: new Ext.data.JsonReader (
{
root: "doctors",
id: "doctor_id",
totalProperty: "totaldoctors"
}, [
{name: "doctor_id"},
{name: "doctor_name"}
]
)
}
);

doctorStore.load({params:{'name':'','namelike':true}});

var doctorList = new Ext.form.ComboBox ({
typeAhead: true,
emptyText: "Scegli...",
displayField: "doctor_name",
valueField: "doctor_id",
name: "doctor",
hiddenName: "doctorId",
mode: 'local',
store: doctorStore,
selectOnFocus:true,
forceSelection:true,
allTimeStoreLoad:true
});
Ext.form.ComboBox.prototype.onTriggerClick = function(){
if(this.disabled){
return;
}
if(this.isExpanded()){
this.collapse();
this.el.focus();
}else {
this.hasFocus = true;
if(this.triggerAction == 'all') {
this.doQuery(this.allQuery, true);
} else {
this.doQuery(this.getRawValue());
}
this.el.focus();
}
if(this.allTimeStoreLoad)
this.store.reload({params:{'name':this.getRawValue(),'namelike':true}});
}

doctorList.applyTo('doctorCombo');
});

dende1979
17 Sep 2007, 12:04 AM
Anyone can help me?

I've added the code




var map = new Ext.KeyMap("doctorCombo", {
key: "abcdefghilmnopqrstuvzwyxjk",
fn: function(e){

},
scope: doctorList
});



to assign "keypress" event to my combo, but now I don't know how to get the text value typed by me to call the service with it.

For example I type "ab" and I want to reload the Store (and expand the Combo) as

this.store.reload({params:{'name':'ab','namelike':true}});

after the 'b' key pressing.

Otherwise I can reload the Store and expand the combo only if the combo field is empty (at start or by backspace key pressing):
how can I control that combo field is empty?

Thanks