Reputation: 1
Copied data from one store to another store and assigned store to combo,Combo dropdown shows values but if i select one value it does not get selected and not shown in the combo box as selected value.
Ext.each(abcStore.data.items, function (item) {
if(item.data.isAutoAnalyst == 1) {
Ext.each(item.raw.subservices, function(i){
abcSubStore.add(i);
});
}
});
Upvotes: 0
Views: 646
Reputation: 6009
I have created a two combo box and one button. First combo box has store and some default value. Second combo box has store but no value. When you click on button, first combo box value will be added in second combo box.
I didn't add a condition while adding data from one combo box to another. After clicking on button, second combo box will show all values that is in first combo box and when you select any value it will show in combo text field.
Ext.onReady(function() {
var comboBox1 = new Ext.data.JsonStore({
autoLoad: false,
fields: ['text', 'value'],
data: [{
'text': "Value1",
'value': 'Value1'
}, {
'text': "Value2",
'value': 'Value2'
}, {
'text': "Value3",
'value': 'Value3'
}, {
'text': "Value4",
'value': 'Value4'
}, {
'text': "Value5",
'value': 'Value5'
}, {
'text': "Value6",
'value': 'Value6'
}]
});
var comboBox2 = new Ext.data.JsonStore({
autoLoad: false,
fields: ['text', 'value']
});
Ext.create('Ext.window.Window', {
width: 400,
height: 300,
items: [{
xtype: 'combobox',
id: 'comboBox1',
store: comboBox1,
displayField: 'text',
valueField: 'value',
queryMode: 'local'
}, {
xtype: 'button',
text: 'Copy first combo box store to another combo box store',
handler: function() {
var combo1Store = Ext.getCmp('comboBox1').getStore();
var combo2Store = Ext.getCmp('comboBox2').getStore();
Ext.each(combo1Store.data.items, function(item) {
combo2Store.add(item);
});
}
}, {
xtype: 'combobox',
id: 'comboBox2',
store: comboBox2,
displayField: 'text',
valueField: 'value',
queryMode: 'local'
}]
}).show();
});
Upvotes: 0