View Full Version : Set value of combo box

11 Jan 2011, 12:23 PM
Dear all,

I am trying to set the value of a combo box. The combo box gets the data (all rows) from an external JSON call. The data is loaded into the combo box and submitted on form submit. But I can not set a value for the combo box on form load.

Here is my code:

var dsRole = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'rolejson.php',method:'GET'}),
reader: new Ext.data.JsonReader({root: 'rows',fields: [{name: 'id'},{name: 'displaytext'}]})

var add_form = new Ext.FormPanel ({
items: [
new Ext.form.ComboBox({
fieldLabel: 'Role',
store: dsRole,
triggerAction: 'all',
editable: false

I tried to use "setvalue" but I failed. Could anybody please tell me how to set the value for the combo box?

Thank you for your help!

11 Jan 2011, 1:20 PM
the record should have a field called "role_id", and you should use setValues via the form panel or loadRecord.

12 Jan 2011, 1:04 AM
Although the field is called role_id the problem still remains.

The combo displays the correct ID when the form is displayed but it doesn't show the display text. :(

12 Jan 2011, 1:42 AM
please post the code whare you are trying to load your form or ombobox, code you have posted here has no issues.