PDA

View Full Version : Missing Column Headers in GXT Grid Component within GWT VerticalPanel



paul.hayden
17 Jun 2009, 3:29 AM
Hi,

I wonder if you can help me with this problem. We have an existing GWT 1.5.2 application and are interested in using GXT components within it. To this end, I have successfully placed a GXT grid component within a GWT VerticalPanel but only if the VerticalPanel's horizontal alignment is set to ALIGN_LEFT. If I change it to ALIGN_CENTER or ALIGN_RIGHT the grid's column headers disappear from view.

Sample code follows.

My entry point class:


publicclass Application implements EntryPoint
{
publicvoid onModuleLoad()
{
AppPropsGrid appPropsGrid = new AppPropsGrid(10);

VerticalPanel displayPanel = new VerticalPanel();
displayPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
displayPanel.add(appPropsGrid);

RootPanel pageRootPanel = RootPanel.get("rootPanel");
pageRootPanel.add(displayPanel);
}


}

The AppPropsGrid component class:


publicclass AppPropsGrid extends LayoutContainer
{
private BasePagingLoader<BasePagingLoadConfig,PagingLoadResult<ApplicationProperty>> loader;

private ListStore<BeanModel> store;

private PagingToolBar toolBar;

privateintnoRecords;

private UserDetailsRPCAsync userDetailsRPC;


public AppPropsGrid(int noOfRecords)
{
super();
this.setNoRecords(noOfRecords);

userDetailsRPC = RPCHelper.getUserDetailsService();
}

publicint getNoRecords()
{
returnthis.noRecords;
}

publicvoid setNoRecords(int noRecords)
{
this.noRecords = noRecords;
}

@Override

protectedvoid onRender(Element parent, int index)
{
super.onRender(parent, index);

FlowLayout layout = new FlowLayout(10);
setLayout(layout);

GetAppPropsRpcProxy rpcProxy = new GetAppPropsRpcProxy();

if( this.loader == null )
{
BeanModelReader<BasePagingLoadConfig> reader = new BeanModelReader<BasePagingLoadConfig>();

this.loader = new BasePagingLoader<BasePagingLoadConfig,PagingLoadResult<ApplicationProperty>>(rpcProxy, reader);
// this.loader.setRemoteSort(true);


this.store = new ListStore<BeanModel>(this.loader);

toolBar = new PagingToolBar(this.getNoRecords());
toolBar.bind(this.loader);
}

this.loader.load(0, this.getNoRecords());

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

ColumnConfig column = new ColumnConfig("name",Translator.translate("name"),200);
columns.add(column);

column = new ColumnConfig("typeCode",Translator.translate("type"),80);
columns.add(column);

column = new ColumnConfig("value",Translator.translate("value"),200);
columns.add(column);

ColumnModel cm = new ColumnModel(columns);

Grid<BeanModel> grid = new Grid<BeanModel>(this.store, cm);
grid.setLoadMask(true);
grid.setBorders(true);
grid.setAutoExpandColumn("name");

ContentPanel gridPanel = new ContentPanel();
gridPanel.setFrame(true);
gridPanel.setCollapsible(true);
gridPanel.setAnimCollapse(false);
gridPanel.setButtonAlign(HorizontalAlignment.CENTER);
gridPanel.setHeading("Test Heading");
gridPanel.setLayout(new FitLayout());

gridPanel.add(grid);
gridPanel.setSize(600,400);
gridPanel.setBottomComponent(toolBar);

add(gridPanel);

}

public BasePagingLoader<BasePagingLoadConfig,PagingLoadResult<ApplicationProperty>> getLoader()
{
returnloader;
}

publicvoid refresh()
{
this.reset();
this.getLoader().load();
}

public ListStore<BeanModel> getStore()
{
returnstore;
}

publicvoid reset()
{
this.getStore().removeAll();
}

privateclass GetAppPropsRpcProxy extends RpcProxy<BasePagingLoadConfig,PagingLoadResult<ApplicationProperty>>
{
@Override

protectedvoid load(BasePagingLoadConfig loadConfig,
AsyncCallback<PagingLoadResult<ApplicationProperty>> callback)
{
BasePagingLoadConfig config = (BasePagingLoadConfig)loadConfig;

userDetailsRPC.getApplicationProperties(
Cookies.getCookie(CommonConstants.SESSION_COOKIE_NAME),
config,
callback );
}
}
}

Animal
17 Jun 2009, 3:43 AM
Nobody in this folder will be able to help. Try the GXT Help folder.

paul.hayden
17 Jun 2009, 4:24 AM
Sorry, my mistake.