【问题标题】:Extjs 4 - Cannot call method 'on' of undefinedExtjs 4 - 无法调用未定义的“on”方法
【发布时间】:2013-11-09 10:06:31
【问题描述】:

我真的一直在尝试向我的网格添加过滤器功能。我的网格在视图中定义,如下所示:

Ext.define('magiq.view.Partners.GrdPartners',{
extend: 'Ext.grid.Panel',
alias:'widget.gridPartners',
store:MyStorePartners, 
border: false,
features: [{ftype: 'filters',
        autoReload: true,
        local: true}],
listeners: {
        'selectionchange': function(view, records) {
            this.down('#delete').setDisabled(!records.length);
        }
},
initComponent: function() {
    var me = this;
    Ext.applyIf(me, {
        columns : [
                {
                  xtype: 'rownumberer',
                  width: 25,
                  sortable: false
                },
               {header:"Id",dataIndex:"id",width:50,hidden:true},
               {header:"Partner",dataIndex:"Partner",flex:1, filter: {type: 'string'}},
               {header:"CUI",dataIndex:"CUI",flex:1},
               {header:"Fiscal Code",dataIndex:"FiscalCode",flex:1},
               {header:"Phone",dataIndex:"Phone",flex:1}

        ],
        dockedItems: [
                {
                xtype: 'toolbar',
                dock: 'top',
                items: [
                    {
                    itemId: 'Add',
                    text: 'Add',
                    iconCls: 'add',
                    action:'add'
                    },'-',{
                    itemId: 'edit',
                    text: 'Edit',
                    iconCls: 'edit',
                    scope: this,
                    action:'edit'

                    },'-',{
                    itemId: 'delete',
                    text: 'Delete',
                    iconCls: 'delete',
                    disabled: true,
                    action:'delete' 
                    },'-',{
                    xtype: 'searchfield',
                    emptyText: 'Search for Partners',
                    store:me.store,
                    width: 400,
                    fieldLabel: 'Search',
                    labelWidth: 50,
                    name:'mySearchfield'
                    }               
                ]
            },
            {
                xtype: 'pagingtoolbar',
                dock: 'bottom',
                displayInfo: true,
                store:me.store,
                displayMsg: 'Displaying records {0} - {1} of {2}',
                emptyMsg: "No records to display",
                items: [
                  {
                    xtype: 'tbseparator'
                  },
                  {
                    xtype: 'button',
                    text: 'Print',
                    iconCls: 'print',
                    action:'print' 
                  }

                ]
            }
        ],

    });

    me.callParent(arguments);
    me.store.load();

}


    });

我的 app.js:

Ext.Loader.setConfig({
enabled : true,
paths   : {
    magiq   : "App"

}
});
Ext.Loader.setPath('Ext.ux', 'resources/ux');
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.ux.grid.FiltersFeature','Ext.ux.grid.menu.ListMenu',
    'Ext.ux.grid.menu.RangeMenu',
    'Ext.ux.grid.filter.BooleanFilter',
    'Ext.ux.grid.filter.DateFilter',
    'Ext.ux.grid.filter.ListFilter',
    'Ext.ux.grid.filter.NumericFilter',
    'Ext.ux.grid.filter.StringFilter'
]);
Ext.application({  
    name        : "magiq", 
    controllers : ['Partners.Partners'],
    launch      : function(){  
          var MyViewPrincipal = Ext.create("magiq.view.Principal.MyViewport")
         } 
});

当我尝试初始化网格时出现此错误:

未捕获的类型错误:无法调用 FiltersFeature.js 中未定义的方法“on”。看起来我的网格是未定义的。 我究竟做错了什么? 请帮忙。

【问题讨论】:

    标签: extjs


    【解决方案1】:

    initComponent: function()Ext.applyIf(me,... 中有一个不必要的,
    dockedItems:[] 的结束] 括号之后

    ],下方的第一行中删除,

            ],
    
        });
    
        me.callParent(arguments);
        me.store.load();
    
    }
    

    【讨论】:

    • 在“grid.on”上仍然出现同样的错误:无法调用 FiltersFeature.js 中未定义的方法“on”
    猜你喜欢
    • 2013-12-08
    • 1970-01-01
    • 1970-01-01
    • 2013-01-01
    • 1970-01-01
    • 2015-03-26
    • 1970-01-01
    • 2013-04-24
    • 1970-01-01
    相关资源
    最近更新 更多