tags:

views:

382

answers:

4

I run into an interesting problem while was using combos in input form. My form contains combos that get data from json stores. It works fine when adding new record, but when the form is opened for editing an existing record, sometimes the id appears as selected not its value (eg: there's 5 instead of "apple"). I think it tries to set the value before it finishes loading the combo.

I check Combo store count and it returns zero this means selection done before combo is loaded. i try to set value in load event and fire select event but it does not work It works well when i reselect another record at that time store is loaded

i also see this thread but it does not give feasible answer http://stackoverflow.com/questions/2506312/extjs-combo-setting-problem

Is there anyway to set its text?

Can anybody give me right soln please?

A: 

Are you use standard ExtJs method setValue to set value in comboBox?

Check that you set value inside Ext.onReady(...);

Or if you load values by ajax you can use update method with callback as 3rd parameter (see at http://dev.sencha.com/deploy/dev/docs/ -> ComboBox)

Xupypr MV
A: 

Could you please post some sample code of the combo box as well as how you are loading/binding the returned values?

It Grunt
A: 

var partyType_store = new Ext.data.Store( { autoLoad: false ,autoDestroy:true

//Note that I have renamed the web service proxy class ,proxy: new Ext.data.HttpProxy({ url: accounts.webService + '/GetType', // ASP.NET WebService call in GET format headers: {'Content-type': 'application/json'} });

,fields :['AccountTypeId','AccountTypeName'] ,listeners{ load:function(){ Ext.getCmp('cmbPartyType').setValue(Ext.getCmp("txtId").getValue()); Ext.getCmp('cmbPartyType').fireEvent("select"); } }
},

//Combo is defined as xtype:'combo' ,width : 150 ,fieldLabel: 'Party Type' ,name: 'PartyType' ,id:'accounts-cmbPartyType' ,store: partyType_store ,displayField:'PartyType' ,valueField:'PartyTypeId' ,hiddenName: 'PartyTypeId' ,mode:'local' // important property when using store ,typeAhead: true ,triggerAction: 'all' ,selectOnFocus:true ,allowBlank:true ,forceSelection:true

i load combo store on event say button click event

Ext.getCmp('cmbPartyType').getStore().load(); //this calls combo load event It works fine if i set autoLoad=true in store But actually i dnt want to load store initially to reduce traffic until user press button

Saima
A: 

Why is the mode set to local instead of remote? Have you used FireBug to make sure the data being sent from the ASP service is formatted correctly?

I'm a little unclear about what you are expecting in the store for these two items:
valuefield: 'PartyTypeId' <-- Is this a number or acode? 5?
displayField: 'PartyType' <-- Is this a number or code? apple?

It Grunt