-1

我有一个组合框,我想创建该组合的新商店实例。我可以看到可以创建一个商店实例,Ext.create('My.Store') 但这在Extjs 2.3.0

我试过了

var comb= new this.combobox1.store; // Gives error store is not a constructor

var comb= new this.combobox1.getStore(); // com is undefined here

任何想法。

4

1 回答 1

0

我知道这已经晚了一年,但迟到总比没有好,因为我发现它没有得到答复,试试这个:

首先创建您的商店:

 var myComboStore = Ext.create('Ext.data.Store', {
     storeId:'myComboStore',
     fields: ['name', 'value'], 
     data: [
         {'name':'shelf1', 'value':'shelf1 val'}, 
         {'name':'shelf2', 'value':'shelf2 val'}, 
         {'name':'shelf3', 'value':'shelf3 val'}, 
         {'name':'shelf4', 'value':'shelf4 val'}  
     ] 
 });

然后在您的组合配置中,分配商店。此面板 (fp) 是用于保存示例组合的简单形式。

var fp = {
  xtype      : 'form',
  frame      : true,
  labelWidth : 110,
    items: 
     {
         xtype: 'combobox',
         fieldLabel: 'My Combo',
         displayField: 'name',
         width: 320,
         store: myComboStore, // ASSIGN STORE TO COMBO
         queryMode: 'local',
         typeAhead: true,
         emptyText : '-none-',
         listeners : {
          //click events for item selection goes here
        }
    }

}

为面板创建一个窗口进入

  new Ext.Window({
      title   : '',
      layout  : 'fit',
      height  : 180,
      width   : 320,
      border   : false,
      items   : fp
  }).show();

工作小提琴:https ://fiddle.sencha.com/#fiddle/1cta

于 2016-06-29T19:50:37.557 回答