Search code examples
javascriptextjsdesktoptaskbar

Extjs add a button to Desktop TaskBar QuickStart


I need to add a button to the taskbar quickstart, but i do not want to open a module window, for example a logout button that will show a confirm messagebox, i have tried like this:

    getTaskbarConfig: function () {
            var ret = this.callParent();
            me = this;
            return Ext.apply(ret, {
                quickStart: [
                    { name: 'Window', iconCls: 'icon-window', module: 'ext-win' },
                    { name: 'Logout', iconCls:'logout', handler: me.onLogout}
                ]
            });
        },
onLogout: function () {
        Ext.Msg.confirm('Logout', 'Are you sure you want to logout?');
    },

And i changed the getQuickStart function of the TaskBar.js file to this:

getQuickStart: function () {
        var me = this, ret = {
            minWidth: 20,
            width: Ext.themeName === 'neptune' ? 70 : 60,
            items: [],
            enableOverflow: true
        };

        Ext.each(this.quickStart, function (item) {
            ret.items.push({
                tooltip: { text: item.name, align: 'bl-tl' },
                overflowText: item.name,
                iconCls: item.iconCls,
                module: item.module, 
                //handler: me.onQuickStartClick, **original code**
                handler: item.handler == undefined ? me.onQuickStartClick : item.handler,
                scope: me
            });
        });

        return ret;
    }

But it does not work, is there a way to add a simple button to the taskbar quickstart?


Solution

  • Thanks for your reply. I have solved the issue. In the TaskBar.js file i changed this line:

    handler: item.handler == undefined ? me.onQuickStartClick : item.handler
    

    for this one:

    handler: item.handler ? item.handler : me.onQuickStartClick
    

    Actually, for me, both do the same, but for any weird reason the code works with that change.