PDA

View Full Version : ComponentQuery other than `widget.` alias



zerkms
19 Mar 2012, 3:10 PM
I'm following the guide at http://docs.sencha.com/ext-js/4-0/#!/guide/application_architecture-section-5 and noticed that here:


init:function(){
this.control({'userlist':{ itemdblclick:this.editUser }}); },

`userlist` alias is used. What other selector could be specified here if, for example, I rendered my grid to a div with id="foo".

Specifying '#foo' or '#foo panel' don't work - double click event isn't attached to a grid. While 'panel' selector does work.

So is there a way to incorporate an id of the div the grid is rendered to?

vietits
19 Mar 2012, 3:27 PM
If you want to query grid by id or itemId you should assign value to grid id/itemId not for the div where the grid is rendered to. Suppose you assign 'foo' for itemId of the grid:


Ext.define('AM.view.user.List' ,{
extend: 'Ext.grid.Panel',
alias : 'widget.userlist',


title : 'All Users',
itemId: 'foo',
....



then you can use '#foo' for the selector in calling control method


init:function(){
this.control({
'#foo':{
itemdblclick: this.editUser
}
});
},

You also can use use grid attributes for selector, ex:


init:function(){
this.control({
'grid[title="All Users"]':{
itemdblclick: this.editUser
}
});
},

zerkms
19 Mar 2012, 3:29 PM
Got it, thank you