Web applications extjs4应用程序中的水平导航栏

Web applications extjs4应用程序中的水平导航栏,web-applications,extjs,yii,Web Applications,Extjs,Yii,我想将水平导航栏添加到由extjs4.1开发的应用程序中,为此我将工具栏添加到视口中 var toolbar = Ext.create('Ext.toolbar.Toolbar', { id: 'header', region: 'north', items: [ { // xtype: 'button', // default for Toolbars text: 'Button' },

我想将水平导航栏添加到由extjs4.1开发的应用程序中,为此我将工具栏添加到视口中

var toolbar = Ext.create('Ext.toolbar.Toolbar', {
    id: 'header',
    region: 'north',
    items: [
        {
            // xtype: 'button', // default for Toolbars
            text: 'Button'
        },
        {
            xtype: 'splitbutton',
            text : 'Split Button'
        },
        // begin using the right-justified button container
        '->', // same as { xtype: 'tbfill' }
        {
            xtype    : 'textfield',
            name     : 'field1',
            emptyText: 'enter search term'
        },
        // add a vertical separator bar between toolbar items
        '-', // same as {xtype: 'tbseparator'} to create Ext.toolbar.Separator
        'text 1', // same as {xtype: 'tbtext', text: 'text1'} to create Ext.toolbar.TextItem
        { xtype: 'tbspacer' },// same as ' ' to create Ext.toolbar.Spacer
        'text 2',
        { xtype: 'tbspacer', width: 50 }, // add a 50px space
        'text 3'
    ]
});
var viewport = Ext.create('Ext.Viewport', {
    layout: {
        type: 'border',
        padding: 5
    },
    defaults: {
        split: true
    },
    items: [toolbar,{

但我想通过服务器创建水平导航栏,因为任何类型的用户都有特定的导航栏,例如管理员可以在导航栏中看到createUser,但其他用户在导航栏中看不到。我不知道如何使用extjs4中的工具栏来实现这一点。有没有别的办法?或者如何通过服务器为任何用户创建工具栏项目?

因此,例如,当您登录时,您可以通过用户访问从服务器返回与您的工具栏相关的数据(或者以任何方式获取此数据)。 您拥有管理视图的控制器。视图包含工具栏。但默认情况下,工具栏是隐藏的。 可以将-showAdminButtons()、showSimpleUserButtons()等方法添加到工具栏中。 一旦您通过用户访问从服务器获取数据,您就可以检查用户是什么,并在视图中调用所需的方法。 但是我的建议是,如果你的工具栏在用户交互过程中发生了变化,那就创建你需要的所有按钮,并且只在正确的时间显示/隐藏你需要的东西。这将防止每次在dom中创建按钮。否则,如果只创建一次工具栏-例如,在showAdminButtons()方法中创建此按钮。 而且不要忘记规则——不要信任来自客户机的数据。检查是否允许执行此操作