In ExtJS 4, you can do some pretty powerful stuff inside your controllers using ComponentQuery. In the following example, I have a simple grid panel view, and I’m using ComponentQuery in my controller to handle itemcontextmenu events within the grid:

views/Bookmarks.js
Ext.define("ME.view.bookmarks.List", {
   extend: "Ext.grid.Panel",
   alias: "widget.bookmarks",
   store: "Bookmarks",
   scroll: "vertical",
   title: "My Bookmarks",
   initComponent: function() {
      this.columns = [
         {
            text: "Bookmark",
            dataIndex: "title",
            flex: 1,
            renderer: function(value,meta) {
               meta.tdAttr = 'data-qtip="' + value + '"';
               return value;
            }
         },
         {
            text: "Created",
            dataIndex: "created",
            xtype: "datecolumn",
            format: "m-d-y",
            hidden: true
         }
      ];
      this.callParent(arguments);
   }
});
controllers/Bookmarks.js
Ext.define("ME.controller.Bookmarks", {
   extend: "Ext.app.Controller",
   stores: ["Bookmarks"],
   models: ["Bookmark"],
   views:  ["bookmarks.List"],
   init: function() {
       this.control({
           "bookmarks": {
              itemcontextmenu: function(view,record,item,index,e) {
                 var me = this;
                 var r  = record.data;
                 e.stopEvent();
                 if (!item.ctxMenu) {
                    item.ctxMenu = new Ext.menu.Menu({
                       items : [
                          {
                              text: "Delete Forever",
                              icon: "images/delete.png",
                              handler:function(btn) {
                                 me.deletebookmark(record,item);
                              }
                          }
                       ],
                       defaultAlign: "tl"
                    });
                 }
                 item.ctxMenu.showBy(item);
              }
           }
      });
   }
});

First things first. You’ll notice this bit in the view:

alias: "widget.bookmarks"

This allows me to define my class as a custom xtype. This is important because you can use ComponentQuery to select components by xtype. With this in mind, I can now use the alias of my More >