Results 1 to 2 of 2

Thread: button on viewport

  1. #1
    TheMonolith
    Guest

    Default button on viewport

    Hello,
    I tried several ways to place an ordinary button on a viewport that covers the entire window area. My last attempt looks like this:

    Code:
    Ext.onReady(function(){
    
        /* create purple viewport that covers the full window area */
    
        var myViewport = new Ext.Viewport({
            layout: 'fit',
            defaults: {
                bodyStyle: 'background-color: #800080; padding:10px'
            },
            items: [{
                html: 'Panel using FitLayout'
            }]
        }); 
        
        /* add button to viewport */
        
        var myButton = new Ext.Button({
            text: 'bla',
            renderTo: 'myViewport'
            });
    });
    Why is it not working and how do I make it work?

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    Code:
    Ext.onReady(function(){
    
        var myButton = new Ext.Button({
            text: 'bla',
        });
        
        var myViewport = new Ext.Viewport({
            layout: 'fit',
            defaults: {
                bodyStyle: 'background-color: #800080; padding:10px'
            },
            items: myButton
        });
    });
    Only ever render the outermost component (the viewport renders itself automatically).
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •