2016-03-17 69 views
0

我從我的觀點調用兩次控制器函數。出於某種原因,其中一個電話正在工作,而另一個則不在。我對ExtJS相對來說比較新,所以請大家幫忙。列舉者之間的ExtJS範圍

Ext.define('Gsm.view.systemmessages.SystemMessages', { 
    extend: 'Ext.grid.Panel', 
    ... 
    ... 
    ... 
    dockedItems: [{ 
     xtype: 'toolbar', 
     dock: 'top', 
     items: [{ 
      xtype: 'textfield', 
      name: 'searchfield', 
      cls: 'searchfield', 
      listeners: {     
       change: function(field, value){ 
        this.getController().filterStore(value); <-- can not reach controller from here 
       } 
      } 
     }] 
    }], 

    columns: [{ 
     text: 'Tipas', 
     width: 150, 
     dataIndex: 'type', 
     sortable: true 
    }, 
    ... 
    ... 
    ... 
    { 
     ... 
     ... 
     ... 
    }], 

    listeners: { 
     select: function(RowModel, record, index, eOpts){ 
      this.getController().onRowClick(record); <-- can reach controller from here 
     } 
    } 
}); 
+0

分享你的控制器代碼會很有幫助 – lascort

+0

但是控制器與它沒有關係嗎?我的意思是我甚至不能調用控制器,我得到「this.getController()爲null」與dockItem監聽器 – CrazySabbath

回答

1

爲什麼不讓你的監聽器是一個應該自動解析到ViewController上的字符串?

listeners : { 
    select : 'someSelectName' 
} 

listeners : {     
    change : 'someChangeName' 
} 
在你的ViewController

然後,在上面那麼這些方法做onRowClick和filterStore方法調用。基本上將視圖中的邏輯移動到ViewController中。

someSelectName : function(RowModel, record) { 
    this.onRowClick(record); 
}, 

someChangeName : function(field, value) { 
    this.filterStore(value); 
} 
+1

這很好,不僅你解決了我的問題,你改進了我的代碼。 – CrazySabbath

+0

一個很好的小恭維!謝謝! –