PDA

View Full Version : Hidiing Tab Panel



vishal058
3 Jun 2013, 10:30 PM
I am new to extjs .I want to display the tabpanel depending upon the user role.How I can do this?Please show some example code also.

KingWarin
4 Jun 2013, 4:26 AM
I guess you want to show tabs inside of the tabpanel according to the users role (like a salesperson has tabs Addressbook, Mails, Sales while an sysadmin has tabs of addressbook, mails, helpdesk)?

In this case one possibility to solve your problem is creating the tabPanel with no items and adding the items (=tabs) just like needed for the according userrole.


var panel = Ext.create('Ext.tab.Panel', {
width:500,
height:700,
renderTo:Ext.getBody(),
items:[{
title:'Addressbook',
html:'Addressbook is visible to all users'
}]
});

...

if(user==='sysadmin'){
var helpdesk = Ext.create('Ext.panel.Panel',{
title:'Helpdesk',
html:'This is the helpdesk'
});
panel.add(helpdesk);
}
if(user==='sales'){
var sales = Ext.create('Ext.panel.Panel',{
title:'Sales',
html:'This is sales'
});
panel.add(sales);
}

Also the API Docs for TabPanel (http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.tab.Panel) will provide you help with this, as they also discribe how to add (and remove) tabs...

Hope this will help you

Cheers