I have a combobox which looks like below
{
xtype:'combo',
fieldLabel:'Test',
store:['a','b']
}
Without creating Ext store object I am assigning the array to store and it is displaying the values fine.
At some action i want to update the store with ['d','e']
I have tried by assigning the new values to store like below
comboObje.store=['d','e'];
but it is not updating the values.
how to replace the orginal values with new values in the store.
I have a combobox which looks like below
{
xtype:'combo',
fieldLabel:'Test',
store:['a','b']
}
Without creating Ext store object I am assigning the array to store and it is displaying the values fine.
At some action i want to update the store with ['d','e']
I have tried by assigning the new values to store like below
comboObje.store=['d','e'];
but it is not updating the values.
how to replace the orginal values with new values in the store.
Share Improve this question asked Sep 3, 2015 at 16:49 Surya Prakash TummaSurya Prakash Tumma 2,1934 gold badges28 silver badges50 bronze badges3 Answers
Reset to default 9You can create a new store using bindStore
or just load new data to the existing store using loadData
:
combo.store.loadData(['d', 'e'].map(function(item){ return [item]; }));
Working example: https://fiddle.sencha.com/#fiddle/tb1
In version 5.* and higher you can use:
comboObje.setStore(['d','e']);
This doesn't work in previous versions.
Paste the following code into a Sencha Fiddle as a 'proof-of-concept':
Ext.application({
name : 'Fiddle',
launch : function() {
var panel = Ext.create('Ext.form.Panel', {
title: 'test',
items: [{
xtype:'combo',
fieldLabel:'Test',
store:['a','b']
}],
renderTo: Ext.getBody()
});
panel.down('combo').setStore(['d','e']);
}
});
Try this:
comboObje.getStore().loadData([{'field1': 'd'}, {'field1': 'e'}]);
When you assign an array to 'store' config, ExtJS automatically generates field names.