PDA

View Full Version : How to get value from a combo box and use it to reload a store



marxan
25 Jun 2012, 12:36 AM
Hello,

I'm trying to do what mentionned in the title, but I'm not able to retrieve the value when select a value in a combo. At the moment I only try to display the selected value but after having tried many code, I'm still not able to do it.

Is the 'select' event is the right one to do that?
How do I retrieve the value selected in my function, do I need to specify some arguments on this function?


Ext.define('TAB.controller.MainBorder',{
extend: 'Ext.app.Controller',

models: ['IndicatorsGroupsModel','FamilyCompoModel',
'IndicatorsModel', 'CountryModel', 'SerieGridModel'
],

stores: ['IndicatorsGroupsStore','FamilyCompoStore',
'IndicatorStore', 'CountriesStore', 'MetrSeriesStore'
],

views: [
'MainBorder', 'IndicatorGroupCombo',
'FamilyCompoCombo', 'IndicatorCombo',
'AverageWagesCombo', 'CountriesCombo',
'YearsCombo', 'MetrSeriesGrid'
],
init: function()
{
var me = this;
this.control({
'indicatorcombo': {
select: me.getModelGroup
}
});
},

getModelGroup: function(combo,rec)
{

alert(Ext.getCmp('indicatorCombo').getSelectionModel().selected.items);
var ComboIndicator = Ext.getCmp('indicatorCombo');
alert(countryName);
//alert(e.getValue());
//alert(value);


}



});



Thanks in advance,

Regards.

sword-it
25 Jun 2012, 4:30 AM
Hi marxn,

Yes select event is enough to get the selected value of combobox after that you can do what you want here is sample code


items:{
xtype:'combobox',
hiddenName:'show',
store:['USA', 'UK', 'Turkey'],
listeners:{
select : function(combo, record, index){
var value = combo.getValue();
// here you
}
}
}

marxan
25 Jun 2012, 5:46 AM
Thanks, I was actually doing right but I misspecified a data of the combo...

I need now to reload a grid with the selected value of my combobox.

To do so, I have to reload the store related to the grid by passing the argument to my method. I used to do like this in extjs3 but I can't make it work in extjs 4.1




var store = Ext.getCmp('projectCurrentStatus').getStore();
store.removeAll();
Ext.apply(store.baseParams, {
phase: phase,
directorate: directorate,
unit: unit
});
store.load({
params: {
start: 0,
limit: 8
}
})


If anyone could redirect me to working example, that would be great! :-)

Thanks

sword-it
25 Jun 2012, 6:38 AM
store.load({
params:{
start:0, limit:20
}
})

Above is not correct way for Extjs4.1 for more information see http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-method-load


try this one



departmentStore.proxy.extraParams = { start:'0', limit:'20'};departmentStore.load();