Extjs 4 - 无法调用未定义的方法'on'

时间:2013-11-09 10:06:32

标签: extjs

我真的不想尝试为网格添加过滤功能。我的网格在视图中定义,如下所示:

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")
         } 
});

当我尝试初始化网格时,我收到此错误:

未捕获的TypeError:无法在FiltersFeature.js中调用未定义的方法'on'。看起来我的网格未定义。 我究竟做错了什么? 请帮忙。

1 个答案:

答案 0 :(得分:0)

,的{​​{1}} initComponent: function()中有一个不必要的Ext.applyIf(me,...]

的结束dockedItems:[]括号之后

,下面的第一行

中删除 ],
        ],

    });

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

}