Model combobox extjs

Is there a way to associate storage with ExtJS ComboBox without creating a js model (ExtJS 4.1)?

To populate the list of users, do I always need to configure the model first? I would like to skip the following code for each list:

Ext.define('User',{extend:'Ext.data.Model',idProperty:'Id',fields:['Id','Name']}); 
+4
source share
4 answers

You are right, Neil!
I found how to use it:

 var myStore = Ext.create('Ext.data.Store',{ fields:['Id','Name'], data:[ {Id:0,Name:'Yes'}, {Id:1,Name:'No'}, {Id:2,Name:'Maybe'} ] }); var pnl = Ext.create('Ext.panel.Panel', { xtype: 'panel', title: 'My Panel', items: [{ id:'cboField1' xtype:'combobox', fieldLabel:'My Field', displayField:'Name', valueField:'Id', queryMode:'local', store: myStore }] }); 
+3
source

It was convenient for me to create a simple model with two field names, a name, and then use this model in all static repositories (which I use for comboboxes), where a list of values ​​is predefined.

+2
source

If you use Architect, you can specify the array in the store property for ComboBox. It makes no sense to create additional stores and models if you just need a static β€œTitle” ComboBox.

 xtype:'combo', fieldLabel:'Title', name:'division', queryMode:'local', store:['Mr','Mrs','Ms'], displayField:'title', autoSelect:true, forceSelection:true 

ps To change the property of the store to a local array in Architect, you need to select the small icon to the left of the store text and change it to an array instead of the store. enter image description here

+2
source

You do not need to install the model in the store in any situation in Extjs. Set the property of the storage fields.

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.AbstractStore-cfg-fields

Also consider the storage data property for local data.

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-property-data

+1
source

All Articles