Results 1 to 3 of 3

Thread: Can't launch grid view from controller

  1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    2
    Vote Rating
    0
      0  

    Default Answered: Can't launch grid view from controller

    I need to open a view from my controller, but it is not working when the view is a grid. If I change the view to a Window, it works fine. This is the controller code that should launch the view...

    Code:
    Ext.widget('reportwindow', {
        title: tab.title
    });
    Here is the view (a basic grid, taken from one of the examples in the docs...
    Code:
    Ext.define('RB.view.reportWindow', {
        extend: 'Ext.grid.Panel',
        alias: 'widget.reportwindow',
    
    
        title: 'Users',
        store: {
            fields: ['name', 'email'],
            data  : [
                {name: 'Ed',    email: 'ed@sencha.com'},
                {name: 'Tommy', email: 'tommy@sencha.com'}
            ]
        },
        columns: [
            {header: 'Name',  dataIndex: 'name',  flex: 1},
            {header: 'Email', dataIndex: 'email', flex: 1}
        ]
    });
    So when I run this, I get nothing. No errors in the log at all. However, if I change the view to be a window component with a grid inside, it works fine. Here is the code that works.

    Code:
    Ext.define('RB.view.reportWindow', {
        extend: 'Ext.window.Window',
        alias: 'widget.reportwindow',
    
    
        width: '100%',
        height: '100%',
        closable: true,
        minimizable: true,
        autoShow: true,
    
    
        initComponent: function() {
            this.callParent();
    
    
            var grid = Ext.create('Ext.grid.Panel', {
                title: 'Users',
                store: {
                    fields: ['name', 'email'],
                    data  : [
                        {name: 'Ed',    email: 'ed@sencha.com'},
                        {name: 'Tommy', email: 'tommy@sencha.com'}
                    ]
                },
                columns: [
                    {header: 'Name',  dataIndex: 'name',  flex: 1},
                    {header: 'Email', dataIndex: 'email', flex: 1}
                ]
            });
    
    
            this.add(grid);
        }
    });
    Does anyone have any idea why this won't work for a grid?

  2. a grid is an extension of a container which needs to be inside another container (viewport, container, window,...). a window is a floating container (panel) which has build in methods for showing / hiding it.

    so in case you want to show a floating grid, the approach to put it inside a window is fine.

    you should set a layout for your window though (like layout: "fit").

    dynamically adding a grid to an existing container works fine.

    best regards
    tobiu

  3. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751
    Answers
    130
    Vote Rating
    129
      0  

    Default

    a grid is an extension of a container which needs to be inside another container (viewport, container, window,...). a window is a floating container (panel) which has build in methods for showing / hiding it.

    so in case you want to show a floating grid, the approach to put it inside a window is fine.

    you should set a layout for your window though (like layout: "fit").

    dynamically adding a grid to an existing container works fine.

    best regards
    tobiu
    Best regards
    Tobias Uhlig

  4. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    2
    Vote Rating
    0
      0  

    Default

    Ok, that makes sense. Thanks tobiu!

Tags for this Thread

Posting Permissions

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