Is there a way to bind a store to a ExtJS ComboBox without creating a js model (ExtJS 4.1)?
To populate a users combobox I'll always need to set up the model first? I would like to skip the following code for each combobox:
Ext.define('User',{extend:'Ext.data.Model',idProperty:'Id',fields:['Id','Name']});
You're right, Neil!
I've 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
}]
});
If you're using Architect you can specify an array in the store property for the ComboBox. There is no point to create extra stores & models if you just want a static 'Title' ComboBox.
xtype:'combo',
fieldLabel:'Title',
name:'division',
queryMode:'local',
store:['Mr','Mrs','Ms'],
displayField:'title',
autoSelect:true,
forceSelection:true
p.s. In order to change the store property to a local array in Architect you need to select the little icon on the left of the store text and change it to an array instead of a store.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With