PDA

View Full Version : Urgent Help : Get Combo box value - ExtJs 3



rxbass
18 Oct 2012, 3:25 AM
i have two combo boxes, when the user select the combo box1, the 'id' of that combo box should be passed to combo box2 proxy url. Please check my code,


var groups = new Ext.data.JsonStore({
fields: [
{ name: 'id' },
{ name: 'name' }
],
root: 'rows',
autoDestroy: true,
autoLoad: true,
proxy: new Ext.data.HttpProxy({
url : GO.settings.modules.schedule.url + 'groups.php',
}),
reader: new Ext.data.JsonReader({
root: 'rows',
id: 'id',
fields: ['id', 'name']
}),

listeners: {
load: function(obj, records){
Ext.each(records, function(rec){
console.log(rec.get('name'));
});
}
}

});


var taskGroup = new Ext.form.ComboBox({
name : 'Group',
hiddenName : 'group',
id : 'group_id',
triggerAction : 'all',
editable : false,
fieldLabel : 'Group',
value : 'Select a Group',
emptyText:'Select a Group',
queryMode : 'remote',
autoLoad: true,
displayField : 'name',
valueField: 'name',
store : groups,
columns: [
{
dataIndex: 'name',
width: 100
},
{
dataIndex: 'id',
}
],
});



var vehicles = new Ext.data.JsonStore({
fields: [
{ name: 'object_id' },
{ name: 'tr_group_id' }
],
root: 'rows',
autoDestroy: true,
autoLoad: true,
proxy: new Ext.data.HttpProxy({
url : GO.settings.modules.schedule.url + 'vehicles.php?group_id=1',

}),
reader: new Ext.data.JsonReader({
root: 'rows',
id: 'tr_group_id',
fields: ['tr_group_id', 'object_id']
}),

listeners: {
load: function(obj, records){
Ext.each(records, function(rec){
console.log(rec.get('object_id'));
});
}
}

});

// ComboBox with multiple selection enabled
var vehicle = new Ext.form.ComboBox({
name : 'vehicle',
hiddenName : 'vehicle',
triggerAction : 'all',
editable : false,
selectOnFocus : true,
forceSelection : true,
fieldLabel : 'vehicle',
value : 'Select Vehicles',
emptyText:'Select a Vehicle',
queryMode : 'local',
valueField : 'object_id',
displayField : 'object_id',
multiSelect: true,
store : vehicles,
columns: [
{
dataIndex: 'object_id',
width: 100
}
],
});




Here when taskGroup is selected, the 'id' should be passed in vehicle proxy url as group_id. Please let me know, how to get that. Im using extjs 3

sword-it
18 Oct 2012, 6:04 AM
Hi Rxbass,


Add select listeners into the taskGroup combobox, like-


listeners:{
select:function(){
var id = groupCombo.getValue()
, vehicleStore = vehicalCombo.getStore();

vehicleStore.load({params :
{ID : id}
});

}
}


http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-method-load

rxbass
18 Oct 2012, 6:35 AM
Thanks Sword!!!