Hi,
I have to populate a form which contains 2 combobox.
I want to populate the second combobox from the first.
var list1 = new Ext.data.JsonStore({
url: './get_organisme.php',
root: 'orga',
fields: [
{name: 'id'},
{name: 'name'}
]
});
var list2 = new Ext.data.Store();
var fs = new Ext.FormPanel({
frame: true,
title:'Formulaire d'inscription',
labelAlign: 'left',
labelWidth: 150,
width: 480,
waitMsgTarget: true,
defaultType: 'textfield',
items:[{
xtype: 'combo',
id: 'combobox1',
fieldLabel: 'combo 1',
store: list1,
mode: 'remote',
displayField: 'name', Sample Data:: The final piece of the jigsaw for this combobox solution is the code for populating the primary and secondary comboboxes. The following code shows how this http://www.xldynamic.com/source/xld.Dropdowns.htmlHOME |
valueField: 'id',
triggerAction: 'all'
},{
fieldLabel: 'info from combobox1',
name: 'pays_orga'
},{
xtype: 'combo',
id: 'combobox2',
fieldLabel: 'combo 2',
store: list2,
mode: 'remote',
displayField: 'name',
valueField: 'id', Load a ComboBox from a Stored Procedure | System iNetwork:: Jul 15, 2008 Craig: I have used DataSource to populate a combo box and have found I then populate another table [I use table(1) in the dataset] with http://systeminetwork.com/article/load-combobox-stored-procedureHOME | Question Using ComboBoxes in a DataGridView - Visual Basic .NET Forums:: Nov 22, 2008 On form load, I want to populate the entire datagridview with another dataset. I 'd like to have the combobox's text value to be equal to http://www.vbdotnetforums.com/winforms-data-access/30520-using-comboboxes-datagridview.htmlHOME |
triggerAction: 'all'
}]
});
fs.getComponent('combobox1').addListener('select', function(index,combo,record){
var id_list1 = fs.getForm().findField('combobox1').getValue();
fs.getForm().load({
url: './getInfo_organisme.php?id='+id_list1,
method: 'GET',
waitMsg: 'Chargement...',
success: function(form,action){
//Ext.MessageBox.alert('success','OK');
},
failure: function(form,action){
Ext.MessageBox.alert('failure','Pas OK'); Flex Monkey Patches » Blog Archive » Simple Datagrid ComboBox as :: Feb 18, 2008 There is another way Mike, to the original code: DataGrid add How to dynamically populate the combobox inside the data grid? http://blog.flexmonkeypatches.com/2008/02/18/simple-datagrid-combobox-as-item-editor-example/HOME | How to add items manually in combobox. - Infragistics Forums:: 8 posts - Last post: Dec 3, 2008Binding a ComboBox to 30000 items shouldn't really take that long. and then populate the list based on the category they chose. http://forums.infragistics.com/forums/t/13404.aspxHOME |
}
});
});
http://dev.apem.asso.fr/combobox.png
But I don't the way to populate the second combobox depending on the selection of the first.
I try to add this code inside the listener but it's not working :
list2 = new Ext.data.JsonStore({
url: './getOtherAdress_organisme.php?id='+id_orga,
root: 'address',
fields: [
{name: 'id'},
{name: 'name'}
]
});
fs.getComponent('combobox2').store.loadData(adress eList);
Any help is appreciated
Fabien
your second combo is specified as being remote, but has an unconfigured store. typically you would do very similar to how you have it, but also use a jsonstore for the second combo and supply a filter param to its load method so the backend knows what to send back (this of course would be called from within a 'select' listener on combo1):
fs.getComponent('combobox2').store.load({params: {id: 'idFromCombo1'}});
I solved it :
I defined the store of th second combobox as a JsonStore without params :
var list2 = new Ext.data.JsonStore({
url: './getOtherAdress_organisme.php',
root: 'address',
fields: [
{name: 'id'},
{name: 'name'}
]
});
And in the listener I reloaded the store of the combobox with the params of the first combobox:
list2.reload({params: {id: id_list1}});
Thank you devnull !!!
I also am interested for this example, you can give me the html file too?
Could you please post the code to display those boxes from your html file and the server side logic of getorganism? I am trying to do a similar thing but I'm not getting far... :(
Thanks for the help.
But I can't populate my second combobox.
So, I have a form with two combobox :
- the first one is populated by the mode 'remote' and a JsonStore : it's working.
- the second combobox should be populated by a selection in the first combobox :
to do that I add a listener 'select' on the first combobox which populates all the textfield
of the form : I used the form.load method to do it and in case of success I define
the store of the second combobox and load it : but it's not working. I don't find the
problem.
I set the store of the second combobox like this :
var list2 = new Ext.data.Store({
root: 'address',
fields: [
{name: 'id'},
{name: 'name'}
]
});
I set the mode of the second combobox on 'local' and I set the listener like this :
fs.getComponent('combobox1').addListener('select', function(index,combo,record){
var id_list1 = fs.getForm().findField('combobox1').getValue();
fs.getForm().load({
url: './getInfo_organisme.php',
params: 'id='+id_list1,
method: 'GET',
waitMsg: 'Chargement...',
success: function(form,action){
list2 = new Ext.data.JsonStore({
url: './getOtherAdress_organisme.php',
params: 'id='+id_list1,
root: 'address',
fields: [
{name: 'id'},
{name: 'name'}
]
});
list2.load();
},
failure: function(form,action){
Ext.MessageBox.alert('failure','Pas OK');
}
});
});
My second combobox stays empty.
Hi,
here the code for the FormPanel and the two combobox (and the two store of the combobox) :
var list1 = new Ext.data.JsonStore({
url: './get_organisme.php',
root: 'orga',
fields: [
{name: 'id'},
{name: 'name'}
]
});
var list2 = new Ext.data.JsonStore({
url: './getOtherAdress_organisme.php',
root: 'address',
fields: [
{name: 'id'},
{name: 'name'}
]
});
list2.load();
var fs = new Ext.FormPanel({
frame: true,
title:'Formulaire d'inscription',
labelAlign: 'left',
labelWidth: 150,
width: 480,
waitMsgTarget: true,
defaultType: 'textfield',
items:[{
xtype: 'combo',
id: 'combobox1',
fieldLabel: 'combo 1',
store: list1,
mode: 'remote',
displayField: 'name',
valueField: 'id',
triggerAction: 'all',
emptyText: 'Sélectionner un organisme'
},{
fieldLabel: 'info from combobox1',
name: 'pays_orga'
},{
xtype: 'combo',
id: 'combobox2',
fieldLabel: 'combo 2',
store: list2,
mode: 'local',
displayField: 'name',
valueField: 'id',
triggerAction: 'all',
emptyText: 'Sélectionner une adresse'
}]
});
And the server side getOrganisme.php :
$sql = "select id_organisme,nom_organisme from organisme order by nom_organisme asc";
$res = pg_query($sql) or die(pg_last_error());
$i=pg_num_rows($res);
if ($i==0){
$return = array('success' => false,
'msg' => 'Aucun organisme');
}
else{
$return["success"]=true;
$i=0;
while ($row=pg_fetch_array($res)){
$return["orga"][$i]["id_combo1"]=utf8_encode($row["id_organisme"]);
$return["orga"][$i]["name"]=utf8_encode($row["nom_organisme"]);
$i++;
}
}
echo json_encode($return);
It's just a simple php query and a return of the json object.
Fabien.
Nortel Unveils Vision, Strategy for Israeli High-Performance Net
Busy Friday Leads to Strong Close for Net Stocks |