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

  • Home
  • SEARCH
  • 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 7498071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:19:18+00:00 2026-05-29T19:19:18+00:00

I am trying to create a grid that fills the width of a ContentPanel

  • 0

I am trying to create a grid that fills the width of a ContentPanel. The grid should have two columns of equal size that span the entire width of the grid. Resizing the browser window should update the grid size accordingly. I would expect the code below to accomplish this, but the grid does not grow on browser resize and there is a ~15px gap between the second column and the right edge of the grid.

Any ideas?

public class MyGrid extends ContentPanel {

@Override
protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    setLayout(new FillLayout());
    ColumnConfig c1 = new ColumnConfig("value","value", 50);
    ColumnConfig c2 = new ColumnConfig("value1","value1", 50);
    ListStore<ModelData> store = new ListStore<ModelData>();
    for (int i=0; i<10; i++) {
      BaseModelData data = new BaseModelData();
      data.set("value", "value");
      data.set("value1", "value1");
      store.add(data);
    }
    Grid<ModelData> grid = new Grid<ModelData>(store, new ColumnModel(Arrays.asList(new ColumnConfig[] {c1, c2})));
    grid.setAutoHeight(true);
    grid.setAutoWidth(true);
    grid.getView().setAutoFill(true);
    add(grid); 
}

}

  • 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-29T19:19:19+00:00Added an answer on May 29, 2026 at 7:19 pm

    The cause of the extra space on the right of the table is grid.setAutoHeight(). Remove this and it will be gone. Getting the table to resize with the browser seems to require the use of a Viewport (I dont understand why the ContentPanel would grow without the grid in the code above). This code accomplishes what I was trying to do:

    public class MyGrid extends Viewport {
    
      @Override
      protected void onRender(Element parent, int index) {
        super.onRender(parent, index);
    
        setLayout(new FitLayout());
        ColumnConfig c1 = new ColumnConfig("value","value", 50);
        ColumnConfig c2 = new ColumnConfig("value1","value1", 50);
        ListStore<ModelData> store = new ListStore<ModelData>();
        for (int i=0; i<10; i++) {
          BaseModelData data = new BaseModelData();
          data.set("value", "value");
          data.set("value1", "value1");
          store.add(data);
        }
        final Grid<ModelData> grid = new Grid<ModelData>(store, new ColumnModel(Arrays.asList(new ColumnConfig[] {c1, c2})));
        grid.getView().setAutoFill(true);
        ContentPanel panel = new ContentPanel();
        panel.setLayout(new FitLayout());
        panel.add(grid);
        add(panel);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a user control that has a Grid with two rows.
I am trying to create a simple ajax grid that allows me to add
I'm trying to create a page that contains a grid and searching. The issue
I trying to create grid that contains rows with the following structure: item name,
What I'm trying to do is create a Gridview and in the grid have
I have to do a grid like this: Harmonic table I'm trying to create
I'm trying to create a grid that has a store with a PagingMemoryProxy in
I am trying to create an Ajax Telerik grid in Razor that has an
I am trying to create a grid view that is editable and allows deleting,
I'm trying to create a tile grid that can be rearranged. The tiles are

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.