PDA

View Full Version : Combo Box not loading value



maecy
7 Oct 2013, 11:28 PM
I am trying to retrieve the values from database to display on the combo box. Here's my code

combo:


xtype:'combobox',
queryMode: 'local',
store: new dlti.store.ClientListStore(),
displayField: 'username',
valueField: 'id',
name: 'client-list',
editable: false


Store:


Ext.define('dlti.store.ClientListStore', {
extend: 'Ext.data.Store',
model: 'dlti.model.ClientListModel',
proxy: {
type: 'memory',
autosync: true,
reader: {
type: 'json',
root: 'result'
}
}
});


model:


Ext.define('dlti.model.ClientListModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'string'},
{name: 'username', type: 'string'},
]
});

Farish
7 Oct 2013, 11:31 PM
you shouldnt be using queryMode: 'local'. if you remove it then it should work.

http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.ComboBox-cfg-queryMode

maecy
7 Oct 2013, 11:36 PM
Still not working. :\

evant
7 Oct 2013, 11:49 PM
You specified a memory proxy, don't want want an ajax proxy to query the server?

maecy
8 Oct 2013, 12:03 AM
I'm using memory proxy the whole time. And it's the default proxy we're using in our framework.

Orcyano
8 Oct 2013, 1:35 AM
As you are using a memory proxy (which doesn't fetch data from an url), you should provide us with some code on how you insert data into your store?

I'd suggest you take a look at the ajax proxy in the docs. You should use this one instead of your memory proxy. Here is some example, i took the liberty to just edit your code a bit.



Ext.define('dlti.store.ClientListStore', {
extend: 'Ext.data.Store',
model: 'dlti.model.ClientListModel',
proxy: {


type: 'ajax',
url: 'your sync url',
autosync: true,
reader: {


type: 'json',
root: 'result'

}

}
});

maecy
8 Oct 2013, 4:44 AM
EDIT*

I was finally able to retrieve my data from the database to my combobox. Sorry guys, My codes were already right but I wrote my the code in the wrong event that's why it's not doing anything. Thank you for all the help. And btw, I still used the queryMode: 'local' and it's running.