---
title: "解决Ext中一直无法实现ComboBox自动选择第一项的问题。"
author: "topcss"
date: "2012-08-09T09:56:39Z"
tags: []
categories: ["Web前端"]
slug: "ext-combobox"
draft: false
lastmod: "2012-08-09T09:56:39Z"
id: 1626326
url: "https://topcss.iteye.com/blog/1626326"
---

问题所在：因为之前是将data添加到Proxy中了，所以一直出不来结果。

参考链接：http://www.sencha.com/forum/showthread.php?178246-combobox-local-store-and-data-set-default-value&p=725745&viewfull=1#post725745

实现代码：

```
// The data store containing the list of statesv
var states = Ext.create('Ext.data.Store', {
 
    fields: ['abbr', 'name'],
 
    data : [
 
        {"abbr":"AL", "name":"Alabama"},
 
        {"abbr":"AK", "name":"Alaska"},
 
        {"abbr":"AZ", "name":"Arizona"}
 
        //...
 
    ]
}
});



/
// Create the combo box, attached to the states data store
E
Ext.create('Ext.form.ComboBox', {
 
    fieldLabel: 'Choose State',
 
    store: states,
 
    queryMode: 'local',
 
    displayField: 'name',
 
    valueField: 'abbr',
 
    value:'AZ',
 
    renderTo: Ext.getBody()
}
});
```