首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

怎么使用Extjs的Combobox动态显示数据库数据,求实例

2013-03-25 
如何使用Extjs的Combobox动态显示数据库数据,求实例如何使用Extjs的Combobox动态显示数据库数据,求实例[解

如何使用Extjs的Combobox动态显示数据库数据,求实例
如何使用Extjs的Combobox动态显示数据库数据,求实例
[解决办法]


// The data store containing the list of states
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
Ext.create('Ext.form.ComboBox', {
    fieldLabel: 'Choose State',
    store: states,
    queryMode: 'local',
    displayField: 'name',
    valueField: 'abbr',
    renderTo: Ext.getBody()
});

//上面是EXTJS的API上面的例子。你如果想要从数据库里面取数据的话,就把store改一下就OK:
var states = Ext.create('Ext.data.Store', {
     model: 'User',
     proxy: {
         type: 'ajax',
         url: '/users.json',
         reader: {
             type: 'json',
             root: 'users'
         }
     },
     autoLoad: true
 });

热点排行