View Full Version : Auto expand column not working in grid
googelybear
25 Nov 2008, 2:10 AM
Hi,
I have a simple grid (all simple text columns) where I use setAutoExpandColumn() for one of the columns.
Unfortunately it does not work (has no effect). So my basic question is: Are there some special things to consider when using this?
fother
25 Nov 2008, 2:42 AM
post your code.
kolli
25 Nov 2008, 1:35 PM
well the docs for grid setAutoExpandColumn says that is going to fill the specified column with all the remaining space in the grid that is not occupied. Which basically means the grid width is more that the total size of all the columns, else i dont think this is going to show any effect.
googelybear
27 Nov 2008, 3:47 PM
ok so here's the code:
ColumnConfig qcolumn = new ColumnConfig(Question.KEY_TEXT, "Text", 500);
qcolumn.setAlignment(HorizontalAlignment.LEFT);
ColumnConfig answerColumn = new ColumnConfig(Question.KEY_ANSWER, "Answer", 75);
answerColumn.setRenderer(some renderer);
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig(Question.KEY_CODE, "Code", 50));
columns.add(qcolumn);
columns.add(new ColumnConfig(Question.KEY_LESSON, "Lesson", 100));
columns.add(new ColumnConfig(Question.KEY_MIN_POINT, "Min Age", 50));
columns.add(new ColumnConfig(Question.KEY_MAX_POINT, "Max Age", 50));
columns.add(answerColumn);
ColumnModel cm = new ColumnModel(columns);
questionGrid = new Grid<Question>(store, cm);
questionGrid.setLoadMask(true);
questionGrid.setBorders(true);
questionGrid.setAutoExpandColumn(Question.KEY_TEXT);(...)
myPanel = new ContentPanel();
myPanel.setFrame(true);
myPanel.setButtonAlign(HorizontalAlignment.CENTER);
myPanel.setHeading("");
myPanel.setLayout(new FitLayout());
myPanel.add(questionGrid);
myPanel.setSize(900, 400); // 500 + 75 + 50 + 100 + 50 + 50 = 825I can make the panel as wide as I want, the table never gets filled horizontally (there is always space left which could be used by the autoexpand column) ...any ideas? Do you need any more information? thanks a lot!
I am not pretty sure why it is not working for the Question.KEY_TEXT field. The autoexpandcolumn works fine for all the other columns. Probably it is because of the column size of 500. If we set setAutoExpandMax to 1000 explicitly it is working fine
googelybear
2 Dec 2008, 1:47 AM
oh yes you are absolutely right!
The API doc for setAutoExpandMax() is wrong: It states that the default is 1000 - which led me to believe that the default is ok for my case - but if you peak into the code you see that the default value is not 1000 but 500! Which of course had no effect to my 500px wide column.
Thanks a lot man!
luisve
24 Nov 2009, 4:06 AM
I have a grid where I use setAutoExpandColumn() for one of the columns but it does not work when I maximize or resize the window.
The grid is placed into a FlexTable, because I need to paint two columns in the screen, this table is placed into a ContentPanel, and the container of all is a class which extends FlexTable, which is added into a Window.
The code is the next:
panel = new ContentPanel(new FitLayout());
panel.setBorders(false);
panel.setCollapsible(false);
panel.setFrame(true);
panel.setScrollMode(Scroll.AUTO);
panel.setAutoHeight(true);
table = new FlexTable();
table.setWidth("100%");
panel.add(table);
this.setWidget(0,0,panel);
final CCCRPCServiceAsync cCCRPCServiceAsync = GWT.create(CCCRPCService.class);
RpcProxy<PagingLoadResult<CCTTO>> proxy = new RpcProxy<PagingLoadResult<CCTTO>>() {
@Override
public void load(Object loadConfig, AsyncCallback<PagingLoadResult<CCTTO>> callback) {
cCCRPCServiceAsync.findCCTByUserIdPaging(Boolean.TRUE,(PagingLoadConfig) loadConfig, callback);
}
};
PagingLoader<PagingLoadResult<ModelData>> cCTLoader = new BasePagingLoader<PagingLoadResult<ModelData>>(p roxy,
new BeanModelReader());
cCTLoader.setRemoteSort(true);
ListStore<BeanModel> store = new ListStore<BeanModel>(cCTLoader);
GridView gridView = new GridView();
gridView.setForceFit(true);
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("commercialClassificationType",
this.formI18N.getClassificationTypeLabel(), 100));
columns.add(new ColumnConfig("buyingCenterName",
this.formI18N.getBuyingCenterLabel(), 100));
columns.add(new ColumnConfig("buyerDescription",
this.formI18N.getBuyerLabel(), 150));
columns.add(compulsoryColumnConfig);
ColumnModel cm = new ColumnModel(columns);
Grid<BeanModel> grid = new Grid<BeanModel>(store, cm);
grid.setView(gridView);
grid.setLoadMask(true);
grid.setBorders(true);
grid.setAutoHeight(true);
grid.setAutoWidth(true);
grid.setAutoExpandColumn("buyerDescription");
cCTLoader.load();
table.setWidget(0,0,grid);
...
I would like you tell me if I need to do something more in my code to achieve a fine working of the grid's autoexpand.
Thanks a lot.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.