Extjs 4 mvc:引用错误

Extjs 4 mvc: Reference error

本文关键字:引用 错误 mvc Extjs      更新时间:2023-09-26

当我尝试从 URL 中获取要设置的值以设置按钮是否禁用时,我的视图中出现以下错误。

ReferenceError: getUrlParams is not defined

为什么在定义方法时出现此错误?

我的观点

Ext.define('AM.view.commission.CommissionList' ,{
    extend: 'Ext.grid.Panel',
    alias: 'widget.commissionlist',
    store: 'ActiveCommissions',
    initComponent: function() {
        this.columns = [
            {header: 'From', dataIndex: 'from', flex: 2},
            {header: 'To',  dataIndex: 'to',  flex: 2},
            {header: 'Status',  dataIndex: 'status',  flex: 5},
            {header: 'Levels',  dataIndex: 'levels',  flex: 5},
            {header: 'Payment Period',  dataIndex: 'paymentPeriod',  flex:5 }
        ];
        this.buttons = [ {
            id:'addCommissionBtn',
            text : 'Add commission',
            action: 'createcommission',
            disabled: getUrlParams
        }];
        this.callParent(arguments);
    }
    ,getUrlParams: function() {
          var params = Ext.urlDecode(window.location.search.substring(1));
          return params['edit'] || null;
    }
});

您丢失的this,请将其更改为:

disabled: this.getUrlParams()

编辑:

getUrlParams 方法中,您需要返回如下所示的Boolean值:

return params.edit === 'true';