PDA

View Full Version : Grid setHorizontalScroll - simple code illustrating problem



cgokey2
13 Apr 2009, 12:00 PM
I built a Grid and can't seem to enable the horizontal scroll bar. The vertical scroll bar does appear. The column text appears chopped off with elipses (...). None of the sample code has text that appears wider than the columns. Could someone point me to how to enable the horizontal scroll bar for grid and autosize the column width.

I noticed that Table widget has a setHorizontalScrollBar method, is their an equivalent for the Grid class?

Thanks!
Chris

cgokey2
13 Apr 2009, 6:29 PM
I've tried a bunch of different things to no avail to get a horizontal scroll bar in this Window. What do I need to add to this code for each column to automatically expand to the largest column value and have the window contain a horizontal scroll bar?

See example code below which should run...

Any help would be greatly appreciated!

Thanks,
Chris


package gov.nasa.gsfc.gcmd.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.extjs.gxt.ui.client.widget.Text;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
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.layout.FitLayout;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.data.BaseModel;

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

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Test implements EntryPoint
{
public void onModuleLoad() {

RootPanel.get().add(new Text("My Test"));
Window w = createLogWindow();
w.show();
}

public Window createLogWindow() {

Window w = new Window();
w.setCloseAction(Window.CloseAction.CLOSE);
w.setIconStyle("icon-grid");
w.setMinimizable(true);
w.setMaximizable(true);
w.setHeading("Log");
w.setSize(650, 300);
w.setLayout(new FitLayout());

List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(new ColumnConfig("timestamp", "Timestamp", 75));
columns.add(new ColumnConfig("ip", "IP", 75));
columns.add(new ColumnConfig("action", "Action", 100));
columns.add(new ColumnConfig("change", "Changes", 400));

ColumnModel cm = new ColumnModel(columns);

final ListStore<Log> store = new ListStore<Log>();

Grid grid = new Grid(store, cm);
grid.setStyleAttribute("borderTop", "none");
grid.setAutoExpandColumn("change");
grid.setBorders(true);

w.add(grid);

store.add(new Log("1/1/09","127.0.0.1","move","this is a realy long column to push the column outside the window and hopefully see a horizontal scroll bar"));
store.add(new Log("1/2/09","127.0.0.1","copy","this is a realy long column to push the column outside the window and hopefully see a horizontal scroll bar"));
store.add(new Log("1/3/09","127.0.0.1","delete","this is a realy long column to push the column outside the window and hopefully see a horizontal scroll bar"));
store.add(new Log("1/4/09","127.0.0.1","rename","this is a realy long column to push the column outside the window and hopefully see a horizontal scroll bar"));
store.add(new Log("1/5/09","127.0.0.1","copy","this is a realy long column to push the column outside the window and hopefully see a horizontal scroll bar"));
store.add(new Log("1/6/09","127.0.0.1","cut","this is a realy long column to push the column outside the window and hopefully see a horizontal scroll bar"));
store.add(new Log("1/7/09","127.0.0.1","paste","this is a realy long column to push the column outside the window and hopefully see a horizontal scroll bar"));

return w;

}


}
class Log extends BaseModel {
public Log(String dateTime, String ip, String action, String change) {
set("timestamp", dateTime);
set("ip", ip);
set("action", action);
set("change", change);
}
}