0

当我尝试从 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;
    }
});
4

1 回答 1

1

您的缺失this,将其更改为:

disabled: this.getUrlParams()

编辑:

在您的getUrlParams方法中,您将希望返回Boolean如下值:

return params.edit === 'true';
于 2013-10-22T14:11:52.020 回答