-
9 Jul 2010 7:59 AM #1
[CLOSED] Grid column width is incorrect if grid is hidden store is added
[CLOSED] Grid column width is incorrect if grid is hidden store is added
- GWT 2.0.3
- GXT - Latest 2.2 build
- Windows 7
I noticed that the column width of a grid will be incorrect if the store is updated while the grid has been removed from the layout.
Steps to reproduce:
- Click on "Add items to Grid" button, notice that elements will be correctly added
- Click on "Remove Panel"
- Click on "Add Panel" and notice that the column width is still correct
- Now click on "Remove Panel" again
- Then "Add items to Grid" button
- Then finally re-add the panel by clicking "Add Panel"
Thanks
Code:public class GridColumnDemo extends LayoutContainer { private ContentPanel panel; private ListStore<ModelData> store; public GridColumnDemo() { Button removeBtn = new Button("Remove Panel", new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { remove(panel); } }); Button addBtn = new Button("Add Panel", new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { add(panel); layout(); } }); Button addStoreBtn = new Button("Add items to Grid", new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { addStore(); } }); panel = new ContentPanel(); panel.setHeading("Bug?"); panel.setLayout(new FitLayout()); panel.setHeight(200); panel.setWidth(500); store = new ListStore<ModelData>(); Grid<ModelData> grid = new Grid<ModelData>(store, getColumnModel()); grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); grid.setStripeRows(true); grid.setAutoExpandColumn("name"); grid.setAutoExpandMax(2000); grid.setAutoExpandMin(100); grid.setLoadMask(true); panel.add(grid); add(addBtn); add(removeBtn); add(addStoreBtn); add(panel); } private void addStore() { List<ModelData> models = new ArrayList<ModelData>(); for (int i = 0; i < 5; i++) { Animal animal = new Animal(); animal.set("name", "Animal nr. " + i); models.add(animal); } store.removeAll(); store.add(models); } private ColumnModel getColumnModel() { List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); ColumnConfig column = new ColumnConfig("name", "Name", 497); configs.add(column); return new ColumnModel(configs); } } class Animal extends BaseModel { }
-
9 Jul 2010 8:01 AM #2
Well, when something is not there, it has no dimensions. This means it cannot be layouted.
When readding the grid, call refresh on the gridview.
We are looking into changing internals, so that layouting will work in much more cases also if it is hidden. These changes are going into GXT3
But thanks for this details report, as always
-
9 Jul 2010 8:07 AM #3
Code:Button addBtn = new Button("Add Panel", new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { add(panel); layout(); grid.getView().refresh(false); } });
-
9 Jul 2010 10:19 AM #4
Ah.. that makes sense. Thanks!
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
[2.??][CLOSED] ComboBox display incorrect width
By freddys in forum Ext 2.x: BugsReplies: 3Last Post: 2 Dec 2009, 4:29 AM -
[CLOSED] TextField in Grid header messes up column widths despite width="100%"
By drehberger in forum Ext GWT: Bugs (2.x)Replies: 13Last Post: 6 Aug 2009, 4:31 AM -
[CLOSED][3.0rc2] extra nested hbox leads to incorrect width
By bobthebuilder in forum Ext 3.x: BugsReplies: 3Last Post: 26 Jun 2009, 5:07 PM -
Grid column widths not correct when grid is initially rendered in a hidden div
By Zeus_Apollo in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 8 Jun 2009, 8:41 AM -
Need help! Hidden column/Data store /Grid
By pokerking400 in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 15 May 2008, 9:12 AM


Reply With Quote