PDA

View Full Version : Link on TabPanel



MatthiasCyber
30 Aug 2010, 11:59 PM
Hello everyone,

I'm trying to do a link when clicking on a Tab item in a TabPanel. I mean, when I click on the Tab, it must redirect me on another page.

Can we do that? And if we can, how can we? :-?

Thanks for the support and for ExtJS

laurentParis
31 Aug 2010, 1:41 AM
You can used listeners on tabpanel



listeners: {
tabchange: function (tabpanel, tab) {
if(....) {document.location.href = 'http://www....';}
}
}

MatthiasCyber
31 Aug 2010, 1:51 AM
It's tryed what you said but I dunno where to put the code you gave to me. I've tryied like that:

{
name: 'TabDeco',
title: 'Déconnexion',
listeners: {
tabchange: function (TabPanel, TabDeco) {
{document.location.href = '/pages/logout';}
}
}

}
But doesn't work, so, what do I do?

Thanks

Animal
31 Aug 2010, 2:17 AM
Which class offers a tabchange event?

Does it fire on the individual tabs?

You must know, since you read the API docs to actually find that event!

MatthiasCyber
1 Sep 2010, 1:43 AM
Wich class, what do you mean ? It's the TabPanel item that got a tabchange Event,

From that, how can I do what I want?

Animal
1 Sep 2010, 1:50 AM
As above. If you really think it's a good idea. Which it's not.

MatthiasCyber
1 Sep 2010, 1:52 AM
I don't understand what do you mean by that. It's not a good idea to redirect to somewhere else when clicking on a tab?

Animal
1 Sep 2010, 1:53 AM
No. What's the point in a TabPanel if you don't let it be a TabPanel?

MatthiasCyber
1 Sep 2010, 1:57 AM
Here is what I wanna do: http://img691.imageshack.us/img691/6808/cran3x.png
When I click on the "Déconnexion" tab, it go to the login page.

laurentParis
1 Sep 2010, 1:59 AM
var tabPanel = new Ext.TabPanel({
renderTo: Ext.getBody(),
activeTab: 0,
items: [{
title: 'Tab 1',
html: 'A simple tab'
},{
title: 'Tab 2',
html: 'Another one'
}],
listeners: {
tabchange: function (tabpanel, tab) {
if(tab.title === 'Tab 2') { // << only for example, it's awfull to use on your code ))
document.location.href = 'http://www....';
}
}
}
});

MatthiasCyber
1 Sep 2010, 2:03 AM
Ok it works, thanks :)