【问题标题】:How to reuse the existing store to populate the combobox in Extjs?如何重用现有商店来填充 Extjs 中的组合框?
【发布时间】:2014-05-27 03:53:17
【问题描述】:

我有一个 "Ext.grid.Panel" ,它是使用商店填充的。 组合框需要填充“Ext.grid.panel”第一列中的值。

例如:示例 UI。

 _______
|Button |
 -------
 -----------------------------
  emp name |  emp no
 -----------------------------
  xxx          ABC
  yyy          XYZ
 ----------------------------

问题: 如果用户单击上面的按钮,我需要显示带有组合框的表单作为表单字段的弹出窗口。它需要从 以上网格。我正在使用商店来填充网格。如何使用同一个商店来填充组合框?

【问题讨论】:

    标签: extjs4.1 extjs4.2


    【解决方案1】:

    如果您在网格面板的初始化之外创建商店,您可以在任何地方使用它 - 我有点不习惯,但是在视图/面板的 init 函数中是这样的/container(肯定是一两个错误,因为这只是一年前的 ext 内存),您可能需要在文档中仔细检查所有内容:

    init: function () {
        var store = Ext.create('App.store.Employees').load();
    
        var contextMenu = Ext.create('Ext.menu.Menu', {
            items: {xtype: 'form', items: [
                {xtype: 'combo', store: store}
            ]
        });
    
        var grid = Ext.create('Ext.grid.Panel', {
            store: store,
            columns [....]
        });
    
        Ext.applyIf(this, {
            items: [
                {xtype: 'button', itemId: 'MyButton'},
                grid
            ]
        });
    
        this.callParent(arguments);
    
        var button = Ext.ComponentQuery.query('#MyButton')[0]
        button.getEl().on('contextmenu', function (e) {
            e.preventDefault();
            contextMenu.show(button.getEl());
        });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-11
      • 2013-02-04
      • 2012-03-18
      • 2014-02-11
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      相关资源
      最近更新 更多