PDA

View Full Version : Combo box with Ext data store



jenis35@yahoo.co.in
7 Aug 2012, 10:43 AM
Hi ,

I am unable to load data from my data store. I am using it LOCALLY only, and not REMOTELY. I might bring data from remote location, but not right now. I am using MVC architecture for the app.

Here is my code snippet.

app/store/USStates.js


Ext.define('sample.store.USStates', {
extend : 'Ext.data.Store',
model:'sample.model.USState',
data : [['1', 'OR'], ['2', 'WA']],
triggerAction : 'all',
editable : true,
autoLoad : true

});


app/model/USState.js :



Ext.define('sample.model.USState', {
extend : 'Ext.data.Model',
fields : ['value', 'text']


});


app/controller/Sample.js


Ext.define('sample.controller.XXXXXX', {
extend : 'Ext.app.Controller',


stores : ['USStates'],


models : ['USState']
});


app/view/XXXXX/Edit.js


new Ext.form.ComboBox({
fieldLabel : 'State Certificate',
store : 'USStates',
name : 'stateCertificate',
queryMode : 'local',
valueField : 'value',
displayField : 'text'


}),
I get combo box in the form, but without any values displayed. What am I doing wrong ?

Tim Toady
7 Aug 2012, 11:16 AM
Your data isn't formatted correctly
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store

Unless of course you were using an array store/reader (which you aren't). Also triggeraction and editable don't belong on your store but on your combo. You don't need to autoload with a store with inline data.

jenis35@yahoo.co.in
7 Aug 2012, 11:25 AM
Hi Tim,

Yes, It helps. Thanks a lot. :) But there is one more problem to it, I don't get my combo box values when I edit the record. What can be the problem ? :(

jenis35@yahoo.co.in
7 Aug 2012, 12:02 PM
Hi ,

I found my answer myself. I had used values which were not available in combo. Thanks for all your help.

J.M.