PDA

View Full Version : linked combobox xml



lek
10 Mar 2009, 9:55 AM
hi everyone, i have a problem, i need to dynamicly load the information of two combobox, i mean, one combobox (c1) have some information and when i choose any option of the combobox (c1), the information of the second combobox change... i dont know how to do it.... Please help me...

Someone help me with an example of linked combobox but with arrays, someone can help me how to do it with xml data...

getting form xml

var ciudad = new Ext.data.Store({
// load using HTTP
url: 'city.xml',
autoLoad:true,
reader: new Ext.data.XmlReader({
// records will have a "Item" tag
record: 'ciudad'
}, [
// the "name" below matches the tag name to read, except "availDate"
// which is mapped to the tag "availability"
{name: 'codigo', type: 'string'},'nombre'
])
});


var area = new Ext.data.Store({
// load using HTTP
url: 'city.xml',
autoLoad:true,
reader: new Ext.data.XmlReader({
// records will have a "Item" tag
record: 'area'
}, [
// the "name" below matches the tag name to read, except "availDate"
// which is mapped to the tag "availability"
{name: 'nombre', type: 'string'},'codigo'
])
});

linked comboboxes

fieldLabel:'Select Country'
,valueField:'cid',
store: ciudad,
dataIndex:'codigo',
displayField:'nombre'
,triggerAction:'all'
,mode:'local',
xtype:'combo'
,listeners:{select:{fn:function(combo, value) {
var comboCity = Ext.getCmp('combo-city');
comboCity.clearValue();
comboCity.store.filter('codigo', combo.getValue());
}}
}

},{
fieldLabel:'Select City'
,valueField:'codigo'
,id:'combo-city'
,store: area
,dataIndex:'codigo',
displayField:'nombre'
,triggerAction:'all'
,mode:'local'
,lastQuery:'',
xtype:'combo'
},

it doesnt work, i dont know how to filter with xml data

please help me...

lek
10 Mar 2009, 6:37 PM
Hi everybody, i have a problem, i need to make two linked combobox, both combobox recieve xml data from a Store object, the thing is that i dont know how to link the combobox, some people gave me some options to do it but it didnt work or i dont know how exactly do it...anyway, another option that i tought is convert the store object into a simpleStore object by an algorithm or something, but i dont know how to do it either....

please somebody help me...

and thanks by the way

17 Mar 2009, 6:08 AM
Please refrain from posting dupilicate questions: http://extjs.com/forum/showthread.php?t=62394

tryanDLS
17 Mar 2009, 9:18 AM
Duplicate threads merged.

http://extjs.com/learn/Ext_Forum_Help#Code_Tags

Warebear
23 Mar 2009, 11:45 AM
I'm looking at the same issue...

I have a list of supervisors in XML, and a list of employees in XML.

I was wondering if there is some way to have the data store be conditional?


if(supComboBox == A){
store.load({
callback: function(){
store.filter('supervisor',(/filter expression/));
}})

else if(supComboBox == B){
store.load({
callback: function(){
store.filter('supervisor',(/filter expression/));
}})

would this work or would I need to consider a different solution?


Where would I put this conditional code? Like in the employee data store information or in the combo box store call? Or?

Warebear
23 Mar 2009, 11:51 AM
BTW -- This employee list call would be when a supervisor is selected in the first combo box.

So:

Select combo box supervisor --> change combo box to list of their employees instead of all employees.


I want to list all at first, then if a supervisor is selected, then break it up to "only the employees under that supervisor"