hmm... nothing special about my code, dont think that it is exactly what your are looking for, but here is the code which belongs to the first code i posted.
Code:
var storeTitel = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'getdata.php?r=titel'}),
reader: new Ext.data.JsonReader({
totalProperty: 'results',
root:'items'
}, [{name: 'titel_id', mapping:'id'}, {name: 'titel_name' , mapping:'name'}])
});
storeTitel.load();
titel = new Ext.form.ComboBox({
width:170,
fieldLabel: titel,
name: 'titel',
store: storeTitel,
displayField:'titel_name',
valueField: 'titel_id' ,
typeAhead: true,
mode: 'local',
triggerAction: 'all',
selectOnFocus:true
});
and my form:
Code:
form = new Ext.form.Form({
labelWidth: 75,
reader: new Ext.data.JsonReader({
successProperty: 'success',
root: 'items'
}, Ext.data.Record.create([
{ name: 'titel_name', mapping: 'titel', type: 'string' },
{ name: 'titel_id', mapping: 'id', type: 'int' }
]))
});
I have shortend my code to all i need for the combobox.
Well, if you dont use a form, it will be necessary to set the initial value after recieving your data record. (what i do with form.load). First i thought that form load would set the initial value of the combobox automatic, cause it sets all other form fields (textfields, ...) automatic and all necessary data would be there (?!), but that didnt worked for me, so i set the initial value of comboboxes manual after form.load -> success
May be i didnt get it right, so post some code.