簡體   English   中英

將激活事件綁定到網格面板 Extjs4

[英]Bind activate event to grid panel Extjs4

我想問一下我可以在哪里向我的網格 MVC 添加偵聽器。

當我這樣做時,什么也沒有發生:

Ext.define('myApp.view.reslist' ,{
    extend: 'Ext.grid.Panel',
    alias : 'widget.reslist',
    store : 'resStore',
    listeners: {
          activate: {
            fn: function(e){ 
                console.log('reslist panel activated');
                  }
            }
           },
    dockedItems: [{
           xtype: 'pagbar',
           store: 'resStore',
           dock: 'top',
           displayInfo: true
       }],
       ..... rest of grid configs

它適用於點擊事件:

listeners: {
          activate: {
            fn: function(e){ 
                console.log('reslist panel clicked');
                 }
          }
           }

注意:我的控制器的初始化仍然是空的:

Ext.define('myApp.controller.resControl', {
    extend: 'Ext.app.Controller',

    stores: ['resStore'],

    models: ['resModel'],

    views: ['reslist','pagbar'],

    init: function() {

            // nothing here 
        }
});

視圖的操作和事件進入其適當的控制器。 我的視圖僅包含用於構建和渲染組件的配置和必要方法。 所有事件處理程序、按鈕操作等都在控制器中。 這是我的控制器的樣子:

Ext.define('myApp.controller.resControl', {
    extend: 'Ext.app.Controller',
    stores: ['resStore'],
    models: ['resModel'],
    views: ['reslist','pagbar'],
    init: function() {

        this.control({
            'reslist' : {
                activate: function(e) { 
                        alert('reslist panel activated');
                }               
            }
        });
    }
});

請注意,僅當您使用選項卡面板顯示時,才會在面板上調用 activate 事件。 當通過單擊選項卡激活面板時調用該事件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM