2013-10-22 72 views
0

当我尝试从URL中获取值以设置禁用按钮时,我在视图中看到以下错误。Extjs 4 mvc:引用错误

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

回答

1

你缺少this,将其更改为:

disabled: this.getUrlParams() 

编辑:

getUrlParams方法

你要返回Boolean值如下:

return params.edit === 'true'; 
+0

啊是的,正在让我疯狂......这个我回来了'真'或'虚假',但它仍然设置残疾是'假'即使这应该是'真',我必须施放返回为布尔生效? – theBigOzzy

+0

如果'params ['edit']'是一个字符串,它将是'true'和'disabled'。 –

+0

是的,我做了一个'console.log(params ['edit']);'就在返回之前,它被返回为'true'或'false',但按钮仍然被禁用...你知道吗为什么这是? – theBigOzzy