PDA

View Full Version : Combo defaultvalue



n24005
15 Sep 2009, 7:25 PM
Newbie alert - searched but haven't found this, obviously....

Combo box with remote data store working as expected. Simple data, Name and ID fields, Name is displayed, ID is returned via valueField: and in the variable set in hiddenName: ' affiliation_id'. The box is editable.

Works great - if the string is found in the data store, then the correct ID is returned in affiliation_id.

But if the user enters a string that does not match anything in the data store, the string itself is returned in affiliation_id.

valueNotFoundText is not what I want.... It overwrites the display, but the original, unmatched string is still returned in affiliation_id.

I need something like a "valueNotFoundValue" that is returned via hiddenName if the string that is entered is not found in the data store.

I have temporarily worked around it by having the server side code return a special record if the string is not found. (Or is this really the right solution?)

Thanks,
Jeff


var affiliationStore = new Ext.data.JsonStore({
url: 'affiliation_store.php',
root: 'records',
fields: ['ID', 'Name']});

var affiliation = new Ext.form.ComboBox ({
store: affiliationStore,
displayField: 'Name',
hiddenName: 'affiliation_id',
valueField:'ID',
minChars:4,
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
emptyText: 'Select Affiliation...',
fieldLabel: 'Affiliation'});

jarlau
15 Sep 2009, 7:56 PM
why not use forceSelection: true?

n24005
16 Sep 2009, 2:27 AM
Thanks for the reply.

I can't use forceSelection because I *want* to allow an entry that is not in the data store. If the string is not in the data store, then I will display a new window that will collect more information, then add it to the store.

Thanks,
Jeff

jarlau
16 Sep 2009, 3:16 AM
I'm using this ux (http://www.extjs.com/forum/showthread.php?t=20511) to implement.