-
30 Aug 2011 12:37 PM #1
Can not populate ComboBox with SimpleArrayStore
Can not populate ComboBox with SimpleArrayStore
Hi! I am new in Ext Designer, so sorry if my question woll be stuped.

I am Using Ext4 and Ext Designer 1.2
I need to create a combo and attach it to SimpleArrayStore.
I make all steps from manual (http://cdn.sencha.io/ext-designer/ex...sers-guide.pdf) but still have 0 records in my combo.
Steps I made:
1) Create combo
2) create store with 1 field (MyField1)
3) Adds an array of arrays in the Store’s data attribute [["Search Engine"], ["Online Ad"], ["Facebook"]])
4) Select my store on sombo properties
5) Set value "MyField1" to displayedField and valueField
6) Set triggerAction attribute to “all” and ComboBox mode (queryMode) attribute to local
COMBO
STORECode:Ext.define('MyApp.view.ui.MyComboBox', { extend: 'Ext.form.field.ComboBox', fieldLabel: 'Label', displayField: 'MyField1', queryMode: 'local', store: 'MyArrayStore', valueField: 'MyField1', initComponent: function() { var me = this; me.callParent(arguments); } });
Code:Ext.define('MyApp.store.MyArrayStore', { extend: 'Ext.data.Store', constructor: function(cfg) { var me = this; cfg = cfg || {}; me.callParent([Ext.apply({ storeId: 'MyArrayStore', data: [ [ 'Search Engine' ], [ 'Online Ad' ], [ 'Facebook' ] ], proxy: { type: 'ajax', reader: { type: 'array' } }, fields: [ { name: 'MyField1' } ] }, cfg)]); } });
-
2 Sep 2011 11:44 AM #2
This looks like its configured properly. Did you get this working?
Aaron Conran
@aconran
Sencha Architect Development Team
-
2 Sep 2011 12:48 PM #3
Yes, I use
instead ofCode:[{"Search Engine"}, {"Online Ad"}, {"Facebook"}]
Code:[["Search Engine"], ["Online Ad"], ["Facebook"]]
-
2 Sep 2011 12:50 PM #4
Really??? That shouldn't work
Aaron Conran
@aconran
Sencha Architect Development Team
-
2 Sep 2011 3:24 PM #5
Yes, I get worked combo only after this. By the way,there is no [[],[],[]] structure on Ext4 examples, only [{},{},{}]
-
14 Sep 2011 6:55 AM #6
I followed also the manual step by step and I encounter the same issue but the shadow_m's solution doesn't work for me.
Any idea about what's wrong in my code ?
Code:Ext.define('MyComboBoxUi', { extend: 'Ext.form.field.ComboBox', name: 'test', fieldLabel: 'Label', displayField: 'test', queryMode: 'local', store: 'MyArrayStore', valueField: 'test', anchor: '100%', initComponent: function() { var me = this; me.callParent(arguments); } });Code:Ext.define('MyArrayStoreUi', { extend: 'Ext.data.Store', constructor: function(cfg) { var me = this; cfg = cfg || {}; me.callParent([Ext.apply({ autoLoad: true, storeId: 'MyArrayStore', data: [ 'Hello', 'Hi', 'GoodMorning' ], proxy: { type: 'ajax', reader: { type: 'array' } }, fields: [ { name: 'test' } ] }, cfg)]); } });
-
15 Sep 2011 3:03 AM #7
Found my problem. Data was not correctly formated :
Code:data: [{"test" : "Hello"}, {"test" : "Hi"}, {"test" : "GoodMorning"}],
-
17 Oct 2011 1:25 PM #8
Array definition generated from Ext Designer doesn't work
Array definition generated from Ext Designer doesn't work
Thanks to forum users for finding this bug and helping me solve what the Ext Designer is doing wrong.
I couldn't figure out how I got it to work and then immediately stopped working after Export.
As other people have determined the Array Reader required both the fieldname and data value to be in JSON array format using {} brackets.
But that means you also have to place the field name definition above the data array. This is how I got mine to work... But remember to save a copy - as Export will overwrite.
Code:Ext.define('Quest Timesheets.store.dbRoadConditions', { extend: 'Ext.data.Store', constructor: function(cfg) { var me = this; cfg = cfg || {}; me.callParent([Ext.apply({ autoLoad: true, filterOnLoad: false, sortOnLoad: false, storeId: 'dbRoadConditions', proxy: { type: 'ajax', reader: { type: 'array' } }, fields: [ { name: 'conditions' } ], data: [ {"conditions":"good"}, {"conditions":"bad"}, {"conditions":"ugly"} ] }, cfg)]); } }); /* * Data Array has to be formatted with {} and field names * Data Array must also follow field name definition */


Reply With Quote