Add ExtJS Dinamic Grid to Ext.Net Viewport in Center Region

  1. #1

    Add ExtJS Dinamic Grid to Ext.Net Viewport in Center Region

    I' have this viewport

    <ext:Viewport ID="MainViewport" runat="server" Layout="BorderLayout">
            <Items>
                <ext:Panel ID="PanelCentral" runat="server" Region="Center" Layout="ColumnLayout">
                    <Content>
                        <div id="gridSpace"></div>
                    </Content>
                </ext:Panel>
                <ext:Panel ID="PanelMargenSuperior"     runat="server" Region="North"   Cls="RegionNorth"   Border="false" />
                <ext:Panel ID="PanelMargenInferior"     runat="server" Region="South"   Cls="RegionSouth"   Border="false" />
                <ext:Panel ID="PanelMargenIzquierda"    runat="server" Region="East"    Cls="RegionEast"    Border="false" />
                <ext:Panel ID="PanelMargenDerecha"      runat="server" Region="West"    Cls="RegionWest"    Border="false" />
            </Items>
        </ext:Viewport>
    And create usin ExtJS a GridPanel dinamically:

    // Create the grid and bind it with the data store.
                    grid = new Ext.grid.GridPanel({
                        id: 'gridPrincipal',
                        store: gridStore,
                        cm: new Ext.grid.DynamicColumnModel(gridStore),
                        selModel: new Ext.grid.RowSelectionModel({ singleSelect: true }),
                        enableColLock: true,
                        renderTo: 'gridSpace',
                        //height: '600',
                        //region: 'center',
                        layout: 'fit',
                        title: 'Results',
                        border: false,
                        bbar: bar,
                        pageSize: resultPageSize
                    });
    
                    // render the grid on UI
                    grid.render();
    Then is render to DIV tag gridSpace, but the Grid don't use all height space.

    How can I use all the Height Space with the grid?
    Or how can I create the grid and add it directlly to the MainViewport and create it like center region?
    Attached Thumbnails Click image for larger version. 

Name:	height.png 
Views:	458 
Size:	86.9 KB 
ID:	3974  
  2. #2
    I got a partial solution, but i'm not sure about the results.

    var resizeGrid = function () {
                var width = window.innerWidth - (12 * 2);
                var height = window.innerHeight - (12 * 2);
    
                Ext.getCmp('gridPrincipal').setWidth(width);
                Ext.getCmp('gridPrincipal').setHeight(height);
            };
    An in the resource manager, add a Listener.

        <ext:ResourceManager ID="MainResourceManager" runat="server">
            <Listeners>
                <WindowResize Handler="resizeGrid()" />
            </Listeners>
        </ext:ResourceManager>
    I'm still looking for a better solution.
  3. #3
    Hi,

    You don't need that <div>, just add a grid directly to the PanelCentral. Then it will participate in the layout logic.
    http://docs.sencha.com/ext-js/3-4/#!/api/Ext.Container-method-add

    Example
    PanelCentral.add(new Ext.grid.GridPanel(...));
    And remove the PanelCentral Content.
  4. #4
    Thanks!!! Works Perfect.

    Solution Code:

        <ext:Viewport ID="MainViewport" runat="server" Layout="BorderLayout">
            <Items>
                <ext:Panel ID="PanelCentral" runat="server" Region="Center" Layout="FitLayout">
    
                </ext:Panel>
                <ext:Panel ID="PanelMargenSuperior"     runat="server" Region="North"   Cls="RegionNorth"   Border="false" />
                <ext:Panel ID="PanelMargenInferior"     runat="server" Region="South"   Cls="RegionSouth"   Border="false" />
                <ext:Panel ID="PanelMargenIzquierda"    runat="server" Region="East"    Cls="RegionEast"    Border="false" />
                <ext:Panel ID="PanelMargenDerecha"      runat="server" Region="West"    Cls="RegionWest"    Border="false" />
            </Items>
        </ext:Viewport>
    // Create the grid and bind it with the data store.
                    grid = new Ext.grid.GridPanel({
                        id: 'gridPrincipal',
                        store: gridStore,
                        cm: new Ext.grid.DynamicColumnModel(gridStore),
                        selModel: new Ext.grid.RowSelectionModel({ singleSelect: true }),
                        enableColLock: true,
                        title: 'Results',
                        border: false,
                        bbar: bar,
                        remoteSort: true,
                        pageSize: resultPageSize
                    });
    
                    // render the grid on UI
                    //grid.render();
    
                    // Add to Panel Central
                    PanelCentral.add(grid);
                    PanelCentral.doLayout();
    And remove all code about resizeGrid() function.
  5. #5
    By the way, you can replace
    PanelCentral.add(grid);
    PanelCentral.doLayout();
    with
    PanelCentral.addAndDoLayout(grid);
  6. #6
    Excelent... works perfect too!!!

    Thanks again!!!

Similar Threads

  1. Replies: 2
    Last Post: Jun 18, 2012, 6:43 PM
  2. Replies: 1
    Last Post: Nov 11, 2011, 5:33 PM
  3. [CLOSED] Reload a tab content in a center region IFrame
    By ljcorreia in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jan 22, 2010, 11:45 AM
  4. ExtJs Extender in west region
    By maxdiable in forum 1.x Help
    Replies: 4
    Last Post: Jun 10, 2009, 4:00 AM
  5. [CLOSED] Dinamically add Tab from the IFrame Center region
    By ljcorreia in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Feb 23, 2009, 12:37 PM

Tags for this Thread

Posting Permissions