Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS mask panel while actions are made

Tags:

panel

mask

extjs

I have an Ext west panel from my viewport and I have a handler on a button that first removes all elements from west then ads another element, then does a doLayout(). So there are 3 things this function does on the click of the button. I would like to add a mask to the west panel when the button is clicked and unmask after all 3 tasks are completed.

Here is the panel:

{
                region: 'west',
                id: 'west-panel',
                title: 'West',
                split: true,
                width: 200,
                minSize: 175,
                maxSize: 400,
                collapsible: true,
                margins: '0 0 0 5',
                layout: 'fit'
                items: [leftMenu]
            }

And this is how I do the tasks:

west.removeAll();
west.add(indexHeaderPanel);
west.doLayout();

Is this possible ? I will give more informations if asked. Thank you.

like image 371
Manny Calavera Avatar asked Jun 04 '26 20:06

Manny Calavera


1 Answers

You literally just do mask() and then unmask() before and after your block of code. If something in your code executes asynchronously, then you just make sure that the unmask is done in an appropriate callback. As an example:

    buttons: [{
        text: 'Refresh West Panel',
        handler: function(){
            var w = Ext.getCmp('west-panel');
            w.getEl().mask();
            w.removeAll();
            w.add(indexHeaderPanel); // assuming you have this ref!
            w.doLayout();
            w.getEl().unmask();
        }
    }]

If your logic executes quickly enough you'll never see the masking. To verify that it works you can put in a test delay:

    buttons: [{
        text: 'Foo',
        handler: function(){
            var w = Ext.getCmp('west-panel');
            w.getEl().mask();

            // do whatever

            (function(){
                w.getEl().unmask();
            }).defer(1000, this);
        }
    }]

w.getEl().[un]mask() will mask the entire panel (including header/footer). To mask only the contents, do w.body.[un]mask().

like image 111
Brian Moeskau Avatar answered Jun 07 '26 20:06

Brian Moeskau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!