-
13 Dec 2011 2:50 PM #1
Problem updating a combobox selection list with an ArrayStore
Problem updating a combobox selection list with an ArrayStore
So I have a combo box that uses an ArrayStore for its data. The combo definition looks like this:
And I have the following code to update the store when certain events happen:Code:{ xtype: 'combo', store: store1, mode: 'local', id: obj.rolesCombinedSelectComboId, hidden:!obj.set_btn_add, typeAhead: false, forceSelection: true, //triggerAction: 'all', lastQuery: '', emptyText: 'Please select', width: 85, minListWidth: 200, //tpl: tpl, displayField: 'display_name', valueField: 'event', fieldLabel: 'Add New', tooltip: 'Select an item to create', editable: false }
I got the above code from the following thread:Code:if (!Ext.isEmpty(obj.rolesCombinedSelectComboId)){ var cmb = Ext.getCmp(obj.rolesCombinedSelectComboId); if (!Ext.isEmpty(cmb)){ cmb.store.removeAll(); var newData = []; var arraydata = obj.setRolesCombinedSelectionArray(obj); for (var ad=0;ad<arraydata.length;ad++){ var newRec = new cmb.store.recordType({ id: arraydata[ad][0], display_name: arraydata[ad][1], event: arraydata[ad][2], description: arraydata[ad][3], icon: arraydata[ad][4], xtype: arraydata[ad][5] }); newData.push(newRec); } cmb.store.add(newData); cmb.store.clearFilter(); } }
http://www.sencha.com/forum/showthre...th-ArrayReader
I can see that the store gets updated with the new values, but the combobox dropdown does not display the new data. Can anyone tell me what I'm doing wrong here?
Also, I should mention, I"m using Ext 3.4
-
14 Dec 2011 1:39 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
This is working for me in 3.4.0:
Code:var store = new Ext.data.ArrayStore({ fields : [ 'event', 'display_name' ], data : [ [1, 'One'], [2, 'Two'], [3, 'Three'], [4, 'Four'], [5, 'Five'] ] }); var form = new Ext.form.FormPanel({ renderTo : Ext.getBody(), width : 400, height : 400, title : 'Test', items : [ { xtype: 'combo', store: store, mode: 'local', typeAhead: false, forceSelection: true, //triggerAction: 'all', lastQuery: '', emptyText: 'Please select', width: 85, minListWidth: 200, //tpl: tpl, displayField: 'display_name', valueField: 'event', fieldLabel: 'Add New', tooltip: 'Select an item to create', editable: false } ] }); setTimeout(function() { console.log('add data'); var recs = [], recType = store.recordType; recs.push(new recType({ event : 7, display_name : 'Seven' })); recs.push(new recType({ event : 8, display_name : 'Eight' })); store.add(recs); }, 2000);Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote