【问题标题】:Creating store instance in Extjs 2.3.0在 Extjs 2.3.0 中创建商店实例
【发布时间】:2015-10-22 17:40:39
【问题描述】:

我有一个组合框,我想为该组合创建一个新的商店实例。 我可以看到 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

任何想法。

【问题讨论】:

    标签: javascript extjs combobox store extjs2


    【解决方案1】:

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

    首先创建您的商店:

     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

    【讨论】:

      猜你喜欢
      • 2012-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-21
      • 2014-09-29
      • 2019-03-10
      • 1970-01-01
      • 2012-05-28
      相关资源
      最近更新 更多