简体   繁体   English

如何在ext JS / Sencha中隐藏选项卡面板

[英]How to hide tab panel in ext JS/ Sencha

there is I am getting problem during hiding tab panel in my application. 在我的应用程序中隐藏选项卡面板期间出现问题。 Ok. 好。 I try to what is I am doing in my application.. please see below image 我尝试执行我的应用程序中的操作..请参见下图

在此处输入图片说明

you can see there is multiple tabs. 您可以看到有多个标签。 I want to hide it if user not have access provide by admin. 如果用户没有管理员提供的访问权限,我想隐藏它。 I simply used array to push tab's panel in array, like this. 我只是简单地使用数组将标签的面板推入数组中,就像这样。

 companyManageitems.push(this.Company);
 companyManageitems.push(this.User);
 companyManageitems.push(this.ChangePassword);
 companyManageitems.push(this.Group); //etc

and this array I passed to another tab panel's Items config, Like this. 然后将此数组传递给另一个选项卡面板的Items配置,就像这样。

     this.companyManagePanel = new Ext.tab.Panel({
            cls: 'p-tab-panel',
            activeTab: 0,
            items:companyManageitems
           });

to manage tab access functionality I made a function that return component that I passed to that function if user have access to that component for eg. 为了管理标签访问功能,我创建了一个函数,该函数返回一个组件,如果用户可以访问该组件,则该组件将传递给该组件。 Change password. 更改密码。 Function is like 功能就像

userAccess(this.ChangePassword, 'Change Password');

this return if user not have permission to change password. 如果用户无权更改密码,则返回此内容。 and simply change password tab not get pushed in companyManageitems array, like this 并简单地更改密码选项卡不会像这样在companyManageitems数组中推送

 companyManageitems.push(userAccess(this.ChangePassword, 'Change Password'));

'Change Password' is a permission name. “更改密码”是权限名称。 2nd parameter of userAccess() userAccess()的第二个参数

Problem is that: When function return null when user not have access to that component/tab tab index get changed of other successive tabs. 问题是:当用户无法访问该组件/选项卡的索引时如果函数返回null, 则会更改其他连续的选项卡。 so linking of tab not work out. 因此选项卡的链接无法正常工作。 means this code I written in another view/panel/ not working/ open another tabs that get index no.3 表示我在另一个视图/面板/无法正常工作/打开另一个获得索引编号3的选项卡中编写的代码

this.manageCompany.companyManagePanel.getLayout().setActiveItem(3);

If you want to hide a tab item available at this.Company and the corresponding tabbar entry, do as follows: 如果要隐藏this.Company可用的选项卡项目以及相应的选项卡条目,请执行以下操作:

this.Company.hide();
this.Company.tab.hide();

I am modified code as bellow, 我被修改为下面的代码,

var companyManageitems = [];
        companyManageitems.push(this.companytab);
        companyManageitems.push(this.Usertab);
        companyManageitems.push(this.roletab); 

instead of: 代替:

companyManageitems.push(userAccess(this.this.companytab, 'Company'));
companyManageitems.push(userAccess(this.Usertab, 'Users'));
companyManageitems.push(userAccess(tthis.roletab, 'role'));

means, Simply I pushed all tabPanels in Array companyManageitems[] And hided tabs by index like this, 意思是,我简单地将所有tabPanels推入了阵列companyManageitems []并按这样的索引隐藏了标签,

 if (userAccess(this.ChangepasswordPanel, 'Change Password') == null) {
            Ext.getCmp('companyTabBar').getTabBar().items.get(3).hide();
        }

Its Working....thank you 它的工作...。谢谢

So, what you do is the following: 因此,您将执行以下操作:

this.manageCompany.companyManagePanel.getLayout().setActiveItem(3);

SetActiveItem does indeed allow you to use the index, but it does also allow you to use a specific item or the itemId. SetActiveItem确实允许您使用索引,但也允许您使用特定项目或itemId。

So, what you want to do is maybe the following: 因此,您要做的可能是以下内容:

if(this.manageCompany.companyManagePanel.items.indexOf(this.ChangePassword)>-1 && hasUserAccess('Change Password'))
   this.manageCompany.companyManagePanel.getLayout().setActiveItem(this.ChangePassword);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM