PDA

View Full Version : Issues with ComboBox and XmlReader



jeffinmotion
26 Nov 2007, 5:45 AM
Hi all,

I've run into some issues with a FormPanel displaying a ComboBox using an XmlReader. I've poured over the docs and forums looking for help but haven't yet found answers. Here's my simple example. I'm using a sample XML file here (http://www.alistapart.com/d/usingxml/nutrition.xml)



Ext.onReady(function(){

var fp = new Ext.FormPanel({
items: [new Ext.form.ComboBox({
fieldLabel: 'Food',
hiddenName:'food',
store: new Ext.data.Store({
autoLoad: true,
reader: new Ext.data.XmlReader({
record: "food",
},
['name']
),
proxy: new Ext.data.HttpProxy({url: 'nutrition.xml', method:'GET'})
}),
valueField:'name',
displayField:'name',
typeAhead: true,
triggerAction: 'all',
emptyText:'Enter or select a food...',
selectOnFocus:true,
forceSelection: false,
})]
});

fp.render(document.body);
});


1) typeAhead doesn't seem to work correctly. It doesn't kick in until after I type 4 letters. (When I type 'B', I would except to see two values presented) Also, When I type 'Beef', the combo selects 'Avocado Dip' and presents me the unfiltered list of food.

2) autoLoad on the Store doesn't seem to work. When I click the drop down (or enter 4 or more letters) I notice then that the xml file is loaded (and is also reloaded continually, shouldn't it be cached by default?)

3) As a result of 1, it seems I will be unable to enter in my own new value, because as I finish typing anything, 'Avocado Dip' gets auto selected.

Any insight would be greatly appreciated.

Best,
Jeff

tryanDLS
26 Nov 2007, 8:32 AM
Suggest you spend some time reading the doc for combo, specifically starting with the mode and minchars config entries. Also there is at least one tutorial that's related to combos at http://extjs.com/learn.

jeffinmotion
26 Nov 2007, 9:30 AM
Tim,

Thanks for the reply and nudge to minChars (in regard to mode). I did miss that. I've studied the combo examples and had based my example on them.

Adding "minChars: 0" to my config easily solves the 4 character issue, but I'm more puzzled why:


the lookahead filtering doesn't seem to work (no matter what I type in, all choices are always displayed in the dropdown),
the first option always gets automatically selected when the list loads after entering text in the combo (preventing me from entering in my own new value)
despite adding "autoLoad: true" to my Store and trying "lazyInit: false" in the combo, the combo always reloads the xml doc instead of just once when the ComboBox is constructed.


This framework is excellent, I apologize if my questions seem to show a lack on studying the documentation -- I definitely have been. Any help would be welcomed.

Best,
Jeff