Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 636761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:33:01+00:00 2026-05-13T20:33:01+00:00

I want to include an ExtJS GridPanel inside a larger layout, which in turn

  • 0

I want to include an ExtJS GridPanel inside a larger layout, which in turn must be rendered inside a particular div in some pre-existing HTML that I don’t control.

From my experiments, it appears that the GridPanel only resizes itself correctly if it’s within a Viewport. For instance, with this code the GridPanel automatically resizes:

new Ext.Viewport(
    {
        layout: 'anchor',
        items: [
            {
                xtype: 'panel',
                title: 'foo',
                layout: 'fit', items: [
                    {
                        xtype: 'grid',
                        // define the grid here...

but if I replace the first three lines with the lines below, it doesn’t:

new Ext.Panel(
    {
        layout: 'anchor',
        renderTo: 'RenderUntoThisDiv',

The trouble is, Viewport always renders directly to the body of the HTML document, and I need to render within a particular div.

If there is a way to get the GridPanel to resize itself correctly, despite not being contained in a ViewPort, that would be ideal. If not, if I could get the Viewport to render the elements within the div, I’d be fine with that. All of my ExtJS objects can be contained within the same div.

Does anybody know of a way to get a GridPanel to resize itself correctly, but still be contained inside some non-ExtJS-generated HTML?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:33:01+00:00Added an answer on May 13, 2026 at 8:33 pm

    To resize Ext JS components when they are not in a Viewport, you need to pass along browser window resize events.

    Ext.EventManager.onWindowResize(panel.doLayout, panel);
    

    In your example, store the Panel into var panel, and then set up the event handler after the var declaration but still inside of Ext.onReady.

    Here is a full single page solution:

    <html>
      <head>
        <link rel="stylesheet" href="ext-3.1.1/resources/css/ext-all.css" />
        <script src="ext-3.1.1/adapter/ext/ext-base.js"></script>
        <script src="ext-3.1.1/ext-all-debug.js"></script>
        <script>
          Ext.BLANK_IMAGE_URL = 'ext-3.1.1/resources/images/default/s.gif';
          Ext.onReady(function(){
            var panel = new Ext.Panel({
              renderTo: 'areaDiv',
              layout: 'fit',
              items: [{
                height: 200,
                title: 'foo',
                xtype: 'grid',
                cm: new Ext.grid.ColumnModel([
                  {header: "id", width: 400},
                  {header: "name", width: 400}
                ]),
                store: new Ext.data.ArrayStore({
                  fields: ['id','name'],
                  data: [[1,'Alice'],[2,'Bill'],[3,'Carly']]
                })
              }]
            });
            //pass along browser window resize events to the panel
            Ext.EventManager.onWindowResize(panel.doLayout, panel);
          });
        </script>
      </head>
      <body>
        header
        <div id="areaDiv" style="padding:30px;"></div>
        footer
      </body>
    </html>
    

    Note that I’ve removed the redundant panel (a GridPanel is a Panel, so no need to wrap it), and used layout fit instead of anchor. Layout fit is actually the key to a fluid layout. Make the browser smaller, then bigger. You’ll see the grid always fills the entire width, with the exception of the padding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.