English 中文(简体)
将activate事件绑定到网格面板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 );
                 }
          }
           }

注意:我的控制器的init仍然是空的:

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

请注意,只有在使用选项卡面板显示时,才会在面板上调用激活事件。当通过单击选项卡激活面板时,会调用该事件。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签