PDA

View Full Version : [CLOSED] Grid overlaps ButtonBar when setAutoHeight(true)



thatone
6 Mar 2009, 1:50 PM
Please take a look at this thread:

http://extjs.com/forum/showthread.php?t=61614

With the code there + setAutoHeight(true) to Grid makes it overlaps the ButtonBar.

sven
6 Mar 2009, 1:51 PM
Please post a complete testcase. In that code is no buttonbar

thatone
6 Mar 2009, 2:17 PM
Please post a complete testcase. In that code is no buttonbar

Sorry for the unclear title.

The Grid is wrapped in a ContentPanel.
There is a button that I added to the ContentPanel (this button is added to ButtonBar of ContentPanel right?)

The code test-case is there.

thatone
6 Mar 2009, 2:17 PM
Code



/*
* Ext GWT - Ext for GWT Copyright(c) 2007, 2008, Ext JS, LLC. licensing@extjs.com http://extjs.com/license
*/
package com.extjs.gxt.samples.client.examples.grid;

import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.samples.resources.client.TestData;
import com.extjs.gxt.samples.resources.client.model.Stock;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.extjs.gxt.ui.client.widget.layout.FillLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.table.NumberCellRenderer;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;

public class GridExample extends LayoutContainer {

public GridExample() {
setLayout(new FlowLayout(10));

final NumberFormat currency = NumberFormat.getCurrencyFormat();
final NumberFormat number = NumberFormat.getFormat("0.00");
final NumberCellRenderer<Grid<Stock>> numberRenderer = new NumberCellRenderer<Grid<Stock>>(currency);

GridCellRenderer<Stock> change = new GridCellRenderer<Stock>() {

public String render(final Stock model, final String property, final ColumnData config, final int rowIndex,
final int colIndex, final ListStore<Stock> store) {
double val = (Double) model.get(property);
String style = val < 0 ? "red" : "green";
return "<span style='color:" + style + "'>" + number.format(val) + "</span>";
}
};

GridCellRenderer<Stock> gridNumber = new GridCellRenderer<Stock>() {

public String render(final Stock model, final String property, final ColumnData config, final int rowIndex,
final int colIndex, final ListStore<Stock> store) {
return numberRenderer.render(null, property, model.get(property));
}
};

List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

ColumnConfig column = new ColumnConfig();
column.setId("name");
column.setHeader("Company");
column.setWidth(200);
configs.add(column);

column = new ColumnConfig();
column.setId("symbol");
column.setHeader("Symbol");
column.setWidth(100);
configs.add(column);

column = new ColumnConfig();
column.setId("last");
column.setHeader("Last");
column.setAlignment(HorizontalAlignment.RIGHT);
column.setWidth(75);
column.setRenderer(gridNumber);
configs.add(column);

column = new ColumnConfig("change", "Change", 100);
column.setAlignment(HorizontalAlignment.RIGHT);
column.setRenderer(change);
configs.add(column);

column = new ColumnConfig("date", "Last Updated", 100);
column.setAlignment(HorizontalAlignment.RIGHT);
column.setDateTimeFormat(DateTimeFormat.getShortDateFormat());
configs.add(column);

ListStore<Stock> store = new ListStore<Stock>();
// store.add(TestData.getStocks());

ColumnModel cm = new ColumnModel(configs);

ContentPanel cp = new ContentPanel();
cp.setBodyBorder(false);
cp.setHeading("Basic Grid");
cp.setButtonAlign(HorizontalAlignment.CENTER);
Button addButton = new Button("Populate");
addButton.addSelectionListener(populateHandler(store));
cp.addButton(addButton);
cp.setLayout(new FilLayout());
// cp.setSize(600, 300);

Grid<Stock> grid = new Grid<Stock>(store, cm);
grid.setStyleAttribute("borderTop", "none");
grid.setAutoExpandColumn("name");
grid.setBorders(true);
cp.add(grid);
this.setLayout(new FillLayout());
add(cp);
}

private SelectionListener<ComponentEvent> populateHandler(final ListStore store) {
return new SelectionListener<ComponentEvent>() {

@Override
public void componentSelected(final ComponentEvent ce) {
store.add(TestData.getStocks());

}
};
}
}

sven
6 Mar 2009, 2:26 PM
The supplied code works fine. You only have to have size your layoutcontainer. Also please read the forum guidlines before posting bugs. I suggest to post first in the help forum as all of your 3 reported issues are no issues.

sven
6 Mar 2009, 2:30 PM
Btw, Your code doesn not set autoheight to true.