PDA

View Full Version : help with combo



andryi
24 Nov 2009, 3:57 PM
hi all, how can I update the text in a combo for another, I mean, I have 2 combos, and when I click one, the other should change showing the first element automatically without click on the second combo

fangzhouxing
24 Nov 2009, 8:19 PM
see: http://www.extjs.com/forum/showthread.php?p=381895#post381895

andryi
25 Nov 2009, 6:49 AM
hi fangzhouxing, this code is for populate the second combo from on first, but If I want to show the second item of the second combo only when I clicked the first combo, how do I do?

carol.ext
25 Nov 2009, 10:46 AM
Did you try using the combo's select() function? See ComboBox API (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.ComboBox)

andryi
25 Nov 2009, 2:57 PM
I use this



var abc = function(index){
sp_dsTabla.on('load', function() {
alert(index);
sp_CmbTabla.setValue(sp_dsTabla.getAt(index).data['nameForUser']);
});
};

sp_CmbAlarm.on("select", function(){
index = sp_CmbAlarm.selectedIndex;
sp_dsTabla.removeAll();
sp_GridAlarmLoad();
var modelDest = Ext.getCmp('sp_CmbTabla');
modelDest.store.reload({params: { alarmId: sp_CmbAlarm.getValue(), Action: 'C' }});
});



the index extist but not load the combo ; i have error in this line
"sp_CmbTabla.setValue(sp_dsTabla.getAt(index).data['nameForUser']);"

andryi
26 Nov 2009, 8:31 AM
I have this

this is my first combo


var sp_CmbAlarm =new Ext.form.ComboBox({
id : 'sp_CmbAlarm',
name :'sp_CmbAlarm',
typeAhead : true,
triggerAction : 'all',
lazyRender : true,
store : sp_dsAlarm,
displayField : 'Description',
valueField : 'AlarmId',
forceSelection : false,
disabled : false,
emptyText : '',
resizable : false,
editable : true,
mode : 'local',
loadingText : 'Loading...',
fieldLabel : 'Alarma',
width : 400
});


this is the select function on the first combo


sp_CmbAlarm.on("select", function(){
alert(sp_CmbAlarm.getValue());
sp_dsTabla.removeAll();
sp_dsTabla.reload({params:{alarmId: sp_CmbAlarm.getValue(), Action: 'C'}});
sp_GridAlarmLoad();
});

why I use "reload"? because I want to refresh the text in the second combo, showing the first item

this is my second combo


var sp_CmbTabla =new Ext.form.ComboBox({
id : 'sp_CmbTabla',
name :'sp_CmbTabla',
hiddenName : 'Tabla',
typeAhead : true,
triggerAction : 'all',
lazyRender : true,
store : sp_dsTabla,
displayField : 'nameForUser',
valueField : 'tableId',
forceSelection : true,
emptyText : '',
resizable : false,
editable : false,
mode : 'local',
loadingText : 'Loading...',
fieldLabel : 'Tabla',
width : 160,
maxHeight : 200
});

andryi
26 Nov 2009, 11:45 AM
well I try with this:

this is my first combo


sp_CmbAlarm =new Ext.form.ComboBox({
id : 'sp_CmbAlarm',
name :'sp_CmbAlarm',
typeAhead : true,
triggerAction : 'all',
lazyRender : true,
store : sp_dsAlarm,
displayField : 'Description',
valueField : 'AlarmId',
forceSelection : false,
disabled : false,
emptyText : '',
resizable : false,
editable : true,
mode : 'local',
loadingText : 'Loading...',
fieldLabel : 'Alarma',
width : 400
});


here, when the store "sp_dsTabla" reload , only have one item, and this item I want to visualize in the second combo automatically, that's the reason I use reload, but not works, by now I need to click the second combo to show the unique item and select it


sp_CmbAlarm.on("select", function(){
index = sp_CmbAlarm.selectedIndex;
sp_dsTabla.removeAll();
sp_dsTabla.reload({params:{alarmId: sp_CmbAlarm.getValue(), Action: 'C'}});
sp_GridAlarmLoad();
sp_btnAlarm.setDisabled(false);
});


this is my second combo


sp_CmbTabla =new Ext.form.ComboBox({
id : 'sp_CmbTabla',
name :'sp_CmbTabla',
hiddenName : 'Tabla',
typeAhead : true,
triggerAction : 'all',
lazyRender : true,
store : sp_dsTabla,
displayField : 'nameForUser',
valueField : 'tableId',
forceSelection : true,
emptyText : '',
resizable : false,
editable : false,
mode : 'local',
loadingText : 'Loading...',
fieldLabel : 'Tabla',
width : 160,
maxHeight : 200
});