PDA

View Full Version : Help With Remote ComboBox, It Keeps Reloading



darren
12 Apr 2010, 8:59 AM
Hi guys, basically here is my situation.

I have a combobox that the user selects, then when they selected the option they want, it takes that ID, passes it and loads a store that populates two other remote comboboxes with subitems of the above combobox. The problem is after they load, if I click the comboboxes with the subitems, it resets it because it tries to load the store again. This makes it very annoying for the user. Below is my code:



// Setting the category_id
if (Ext.getCmp('category-combobox') == undefined){
var category_id = 0;
}else{
var category_id = Ext.getCmp('category-combobox').getValue();
}

// The store
var store = new Ext.data.JsonStore({
url: '/data/dropdown_articles',
root: 'articles',
fields: [ 'id', 'title' ],
baseParams: { 'category_id': category_id }
});

// Comboboxes
{
xtype: 'combo',
id: 'category-combobox',
hiddenName: 'category_id',
fieldLabel: 'Category',
store: new Ext.data.JsonStore({
url: '/data/dropdown_categories',
root: 'categories',
fields: [ 'id', 'name' ],
}),
mode: 'remote',
triggerAction: 'all',
displayField: 'name',
valueField: 'id',
allowBlank: false
},{
xtype: 'combo',
id: 'article_1_id-combobox',
hiddenName: 'article_1_id',
fieldLabel: 'Article 1',
store: store,
mode: 'remote',
triggerAction: 'all',
displayField: 'title',
valueField: 'id',
allowBlank: false,
forceSelection: true
},{
xtype: 'combo',
id: 'article_2_id-combobox',
hiddenName: 'article_2_id',
fieldLabel: 'Article 2',
store: store,
mode: 'remote',
triggerAction: 'all',
displayField: 'title',
valueField: 'id',
allowBlank: false,
forceSelection: true
}

// The listener
Ext.getCmp('category-combobox').on('select', function(el){
store.reload({
params: { 'category_id': el.getValue() }
});
});



Does anyone know why its trying to reload the bottom two comboboxes when there is no listener?

Thanks,
Darren

elishnevsky
12 Apr 2010, 10:42 AM
You have your combo boxes with subitems configured with mode:'remote', which makes AJAX request to the server when you click the arrow icons. Since you are loading the store manually, set mode:'local' for these combo boxes.

darren
12 Apr 2010, 12:07 PM
Thanks that worked perfectly.