Forum /
Ext JS Community Forums 3.x /
Ext 3.x: Help & Discussion /
Best way to get index of an element in a Container
Best way to get index of an element in a Container
Hi,
sorry a newbie 'best practices' question.
Inside my Container i have multiple components.
When a user clicks on one of these components i want to know the index of that item within the container.
What is the best way to get this ?
Thanks
Sencha - Community Support Team
myContainer.items.indexOf(myChildContianerRef);
thanks so much !
hey i just bought your book, reading it now. LOVE it
How do I get the container object?
How do I get the container object?
How do I get a container object from a child element? Following is what I'm trying to do, but tr.items returns undefined.
handleHeaderKeyPress: function (event) {
if (event.keyCode == event.ENTER) {
var td = Ext.get (event.target).parent('td' );
if (td) {
var tr = td.parent('tr' );
if (tr) {
var index = tr.items.indexOf(td);
if (index > 0 ) {
this .fireEvent('headerclick' , this , index, null );
return false ;
}
}
}
}
return true ;
},
Sencha - Community Support Team
Hi
I guess td and tr is dom element so you can try instead of tr.items
Regards
sword-it.com ,
Sencha Developer House in
Turkey - Istanbul University Technopark Suite 204.
Similar Threads
By wez.morris in forum Ext 3.x: Help & Discussion
Replies: 3
Last Post: 16 Jun 2010, 11:40 PM
By barbara1712 in forum Ext 3.x: Help & Discussion
Replies: 6
Last Post: 12 Jan 2010, 3:46 AM
By makana in forum Ext 3.x: User Extensions and Plugins
Replies: 0
Last Post: 11 Dec 2009, 9:23 AM
By mojotosh in forum Ext 3.x: Help & Discussion
Replies: 4
Last Post: 19 Oct 2009, 11:43 AM
By dolittle in forum Ext 2.x: Help & Discussion
Replies: 4
Last Post: 10 Feb 2008, 2:20 AM
Tags for this Thread
Sencha is used by over two million developers. Join the community, wherever you’d like that community to be
or Join Us