PDA

View Full Version : using itemId in tab.panel instead of id to fetch tabs



dirtdevil
19 Aug 2012, 8:32 AM
var myTab = this.items.get(rec.internalId);
if( myTab ){
this.getLayout().setActiveItem(myTab);
} else {
this.add({
myModel: rec,
title: rec.data.text,
closable: true,
id: rec.internalId
});
}

I want to fetch the tab but I want to do it using an itemId and not an id. I know tab.panel has getItemId but that gets the itemId of the tab.panel and not the itemId of any of the tabs. So basically...


var myTab = this.items.getTabItemId(rec.internalId);
if( myTab ){
this.getLayout().setActiveItem(myTab);
} else {
this.add({
myModel: rec,
title: rec.data.text,
closable: true,
itemId: rec.internalId
});
}

I know there is a simple way to do it. Probably a method I forgot but I don't know which.

evant
19 Aug 2012, 2:20 PM
var item = this.child('#foo'); // or .down()

dirtdevil
19 Aug 2012, 5:20 PM
That didn't work...


var myTab = this.child('#' + rec.internalId);


returns null. I tried using id and using itemId.

dirtdevil
19 Aug 2012, 5:22 PM
I also tried...


var myTab = this.down('#' + rec.internalId);
console.log(myTab);

dirtdevil
19 Aug 2012, 5:35 PM
I also checked out this link
http://www.sencha.com/forum/showthread.php?129141-Access-to-nested-component-by-itemId

which would logically work.

evant
19 Aug 2012, 7:02 PM
Ext.onReady(function() {

var tabs = Ext.create('Ext.tab.Panel', {
renderTo: document.body,
items: [{
itemId: 'a',
title: 'A'
}, {
itemId: 'b',
title: 'B'
}]
});

tabs.child('#a').setTitle('Foo');
tabs.child('#b').setTitle('Bar');

});

dirtdevil
20 Aug 2012, 8:52 AM
Thanks, I found my problem. My ID structure is all numbers so I use ints in my itemIds. When I put the ids in single quotes, it works fine. Thats why everyone elses examples (including yours) worked fine and mine didn't. Thanks for the help man, I really appreciate it.