PDA

View Full Version : EditorGrid > ComboBox > "Tab" does not commit changes



wjl_77382
4 Feb 2010, 6:48 AM
Hi,

I am trying to create an EditorGrid with a combobox drop down - where the user can either type in their own values, or (as they type) suggested values will be shown to them.

The problem I'm running into is that if you type something new (not in the suggested values) - or something is incomplete - the value is erased or reset.

For example, if the drop down was suggesting US states, and you typed "Calif" and then hit tab - the combobox is be set to "California". Or, if you typed "Califabc" and hit tab - the combobox would reset to "". Instead, I'd like for the combobox to remain "Calif" in the first instance - and "Califabc" in the second. The user can arrow down, or mouse click, the suggested values - if they'd prefer.

Here is my code for declaring the combobox:


editor: new Ext.form.ComboBox({
// combobox configs
minChar: 2,
store: new Ext.data.Store({
proxy: new Ext.data.HttpProxy({ url: 'ddldata.ashx' }),
baseParams: { a: 'lineitem-itemdesc' },
reader: new Ext.data.JsonReader({},
[{ name: 'ItemDesc' }, { name: 'ItemNumber' },
{ name: 'MajorCategory'}, { name: 'MinorCategory' } ])
}),
tpl: new Ext.XTemplate(
'<tpl for="."><div class="search-item">',
'<b>{ItemDesc}</b>&nbsp;<br/>',
'{ItemNumber} | {MajorCategory} > {MinorCategory}&nbsp;',
'</div></tpl>'
),
displayField: 'ItemDesc',
itemSelector: 'div.search-item',
valueField: 'ItemDesc',
forceSelection: false,
loadingText: 'Loading ...',
listEmptyText: 'No results found',
triggerAction: 'all'
})

Thanks in advance for the help ...

wjl_77382
4 Feb 2010, 4:23 PM
Fixed the problem with the following:


listeners: {
specialkey: function(t, e) {
if (e.getKey() == e.TAB) {
t.value = document.getElementById(t.id).value;
}
}
}

Probably isn't the best way to do it - but it's working.

Screamy
16 Feb 2010, 4:51 AM
I was bitten by the same problem when porting an existing applicaiton from 3.1.0 to 3.1.1. All comboboxes in my app (not just those in an Editor Grid) would not accept the highlighted item when the TAB key is pressed.

My solutions was to downgrade back to version 3.1.0, rather than have to visit every single combobox in my app (of which there are plenty) and add temporary patch code...

Hani79
1 Mar 2010, 8:59 AM
Fixed the problem with the following:

Probably isn't the best way to do it - but it's working.

Thanks - your solution was prettier than mine. :)