PDA

View Full Version : [SOLVED] ComboBox not loading data from store



Nightwish
15 Jun 2010, 12:08 PM
This has been driving me crazy and I cannot see what I am doing wrong... it's going to be some simple setting, I know it. Any help appreciated!


MyComboUi = Ext.extend(Ext.form.ComboBox, {
fieldLabel: 'Month/Year',
anchor: '100%',
store: 'MonthYearStore',
valueField: 'ID',
displayField: 'Text',
hiddenId: 'EpisodeMonthYear',
hiddenName: 'EpisodeMonthYear',
mode: 'remote',
forceSelection: true,
initComponent: function() {
MyComboUi.superclass.initComponent.call(this);
}
});

SDMonthYearStore = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
StormDatMonthYearStore.superclass.constructor.call(this, Ext.apply({
storeId: 'MonthYearStore',
root: 'Data',
idProperty: 'ID',
totalProperty: 'TotalCount',
autoSave: false,
url: '/sd/api.svc/lookup/MonthYearData',
autoLoad: true,
restful: false,
sortField: 'ID',
sortDir: 'DESC',
fields: [
{
name: 'ID',
type: 'string'
},
{
name: 'Text',
type: 'string'
}
]
}, cfg));
}
});
new SDMonthYearStore();

j-joey
15 Jun 2010, 2:46 PM
try setting mode to local

Nightwish
15 Jun 2010, 3:00 PM
Thanks, j-joey! That fixes it but I'd like to understand why "local" works when in reality I am retrieving the data via ajax from a web service? When is "remote" appropriate?

j-joey
15 Jun 2010, 11:37 PM
hi,

as you can see in the source code ( http://www.sencha.com/deploy/dev/docs/source/Combo.html#method-Ext.form.ComboBox-doQuery ), basically, mode config property tells where the filtering will be done.

if you choose remote, when you type something on combo it sets baseparams to filter and loads the store.
if you choose local, it just filters the results.

that's all...

Nightwish
16 Jun 2010, 7:47 AM
This will take some getting used to - the ext ComboBox is a lot more powerful than a regular dropdown.