ExtJS 4.1 を使用しています。顧客のリストを含むコンボ ボックスを作成する必要があり、事前に選択された特定の項目を設定したいのですが、その方法がわかりません。コンボボックスを作成するコードは次のとおりです。
xtype: 'combobox',
fieldLabel: 'customer',
name: 'customer_id',
allowBlank:false,
afterLabelTextTpl: required,
//data store
store: Ext.create('Ext.data.Store', {
autoDestroy: true,
model: 'customer_model',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'load.php?item=customer',
reader: {
type: 'json',
successProperty: 'success',
root: 'data'
}
}
}),
valueField: 'id',
displayField: 'company',
typeAhead: true,
queryMode: 'remote',
emptyText: ''
ご覧のとおり、コンボ ボックスにはデータ ストアが表示されています。このデータ ストアは、「customer_model」というデータ モデルに基づいて構築されています。データモデルのコードは次のとおりです。
Ext.define('customer_model', {
extend: 'Ext.data.Model',
fields: [
{type: 'int', name: 'id'},
{type: 'string', name: 'company'},
{type: 'string', name: 'vat'},
{type: 'string', name: 'ssn'},
{type: 'int', name: 'ref_id'}
]
});
ページがロードされたときに特定のアイテム、たとえば id が 1 の顧客が自動的に選択されるように、コンボ ボックスを構成したいと思います。誰でも私を助けることができますか?前もって感謝します。エンリコ。