PDA

View Full Version : ComboBox in Edit mode



pravin_bluebird
24 Nov 2007, 1:12 AM
Hello all,

I have a problem in combobox.
i have two form
one for inserting new values .
second for editing the old values.

on both form i have combobox.

now on second form where i use combobox for editing purpose..
i need to have all combobox value and the old value need to be selected by default.

but instead of value , i everytime got id

here is my code and screenshot


groupedit_form = new Ext.form.Form({
labelWidth: 75,
reader : new Ext.data.JsonReader({
root: 'groups',
totalProperty: 'totalCount'
}, [
{name: 'group_name', mapping: 'name', type: 'string'},
{name: 'description', mapping: 'description', type: 'string'},
{name: 'unit_id', mapping: 'unit_id', type: 'int'},
{name: 'unit_name', mapping: 'unit_name', type: 'string'}
])
});
groupedit_form.column({width:"300",style:'margin-left:10px'});

groupedit_form.fieldset(
{legend:'group'},

new Ext.form.TextField({
fieldLabel: 'Name',
name: 'group_name',
allowBlank: false,
width:190,
align:'right',
vtype:'alphanum'
}),
new Ext.form.TextArea({
fieldLabel: 'Description',
name: 'description',
grow: true,
preventScrollbars:true,
allowBlank:false,
width:190
}),
new Ext.form.ComboBox({
fieldLabel: 'Part of Which Unit',
hiddenName:'unit_id',
editable:false,
store: new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'unit_type.php'}),
reader: new Ext.data.JsonReader(
{root: 'units',
totalProperty: 'count',
unit_id: 'id'},
[{name: 'unit_id', mapping: 'id', type: 'int'},
{name: 'unit_name', mapping: 'name', type: 'string'}
]
)
}),
valueField:'unit_id',
displayField:'unit_name',
typeAhead: true,
triggerAction: 'all',
emptyText:'Select unit...',
forceSelection: true,
allowBlank: false,
width:190
})

);

groupedit_form.end();
groupedit_form.render('editform-group');
groupedit_form.load({url: 'getgroup.php', params:'groupid='+groupid});

fay
24 Nov 2007, 3:32 AM
The only thing that I can see is that you're using the same name ('unit_id') for the hiddenName and valueField config options; try changing hiddenName to 'unitId'. I can't remember why this causes a problem, but it has come up before, and, again, I can't remember in which thread :)

pravin_bluebird
24 Nov 2007, 3:51 AM
ok its work fay,
i change the unit_name in form reader to unitname and combobox hiddenField value to unitname
thats it:)
regards