2013-10-22 69 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