maratkalibek
18 Feb 2010, 10:01 PM
GWT 2.0.2
GXT 2.1.1
Gilead4GWT 1.3.0
------------------------------------------
I'm trying to use Gilead with GXT for displaying bean models in Grid. Bean models are taken from Hibernate, but they are not shown in grid. Code for displaying grid is
RpcProxy<PagingLoadResult<Document>> proxy = new RpcProxy<PagingLoadResult<Document>>() {
@Override
protected void load(Object loadConfig, AsyncCallback<PagingLoadResult<Document>> callback) {
PagingLoadConfig config = (PagingLoadConfig) loadConfig;
mainService.getDocuments(
config.getOffset(),
config.getLimit(),
callback
);
}
};
BeanModelReader reader = new BeanModelReader();
PagingLoader<PagingLoadResult<BeanModel>> loader = new BasePagingLoader<PagingLoadResult<BeanModel>>(proxy,reader);
PagingToolBar toolbar = new PagingToolBar(50);
toolbar.bind(loader);
ListStore<BeanModel> store = new ListStore<BeanModel>(loader);
List<ColumnConfig> columns = new LinkedList<ColumnConfig>();
columns.add(new RowNumberer());
ColumnConfig config = new ColumnConfig();
config.setId("publicNumber");
config.setHeader(strings.name());
config.setMenuDisabled(true);
config.setRenderer(new GridCellRenderer<ModelData>() {
@Override
public Object render(ModelData model, String property,
ColumnData config, int rowIndex, int colIndex,
ListStore<ModelData> store, Grid<ModelData> grid) {
Integer publicNumber = model.get("publicNumber");
String title = strings.noDataInThisLanguage();
String description = "";
DocumentTitle _title = null;
Set<DocumentTitle> titles = model.get("titles");
for (DocumentTitle t : titles) {
if (t.getLanguage().getCode().trim().equals(language)) {
_title = t;
break;
}
}
if (title!=null) {
title = _title.getTitle();
description = _title.getDescription();
}
StringBuffer sb = new StringBuffer();
sb.append("<b>");sb.append(title);sb.append("</b>");
if (!description.trim().equals("")) {
sb.append("<div>");sb.append(description);sb.append("</div>");
}
sb.append("<div>");
return sb.toString();
}
});
columns.add(config);
ColumnModel cm = new ColumnModel(columns);
Grid<BeanModel> grid = new Grid<BeanModel>(store,cm);
grid.setAutoExpandColumn("publicNumber");
grid.getView().setEmptyText(strings.pressSearchToView());
grid.setHeight(200);
grid.setAutoHeight(true);
grid.getView().setForceFit(true);
grid.setLoadMask(true);
GXT 2.1.1
Gilead4GWT 1.3.0
------------------------------------------
I'm trying to use Gilead with GXT for displaying bean models in Grid. Bean models are taken from Hibernate, but they are not shown in grid. Code for displaying grid is
RpcProxy<PagingLoadResult<Document>> proxy = new RpcProxy<PagingLoadResult<Document>>() {
@Override
protected void load(Object loadConfig, AsyncCallback<PagingLoadResult<Document>> callback) {
PagingLoadConfig config = (PagingLoadConfig) loadConfig;
mainService.getDocuments(
config.getOffset(),
config.getLimit(),
callback
);
}
};
BeanModelReader reader = new BeanModelReader();
PagingLoader<PagingLoadResult<BeanModel>> loader = new BasePagingLoader<PagingLoadResult<BeanModel>>(proxy,reader);
PagingToolBar toolbar = new PagingToolBar(50);
toolbar.bind(loader);
ListStore<BeanModel> store = new ListStore<BeanModel>(loader);
List<ColumnConfig> columns = new LinkedList<ColumnConfig>();
columns.add(new RowNumberer());
ColumnConfig config = new ColumnConfig();
config.setId("publicNumber");
config.setHeader(strings.name());
config.setMenuDisabled(true);
config.setRenderer(new GridCellRenderer<ModelData>() {
@Override
public Object render(ModelData model, String property,
ColumnData config, int rowIndex, int colIndex,
ListStore<ModelData> store, Grid<ModelData> grid) {
Integer publicNumber = model.get("publicNumber");
String title = strings.noDataInThisLanguage();
String description = "";
DocumentTitle _title = null;
Set<DocumentTitle> titles = model.get("titles");
for (DocumentTitle t : titles) {
if (t.getLanguage().getCode().trim().equals(language)) {
_title = t;
break;
}
}
if (title!=null) {
title = _title.getTitle();
description = _title.getDescription();
}
StringBuffer sb = new StringBuffer();
sb.append("<b>");sb.append(title);sb.append("</b>");
if (!description.trim().equals("")) {
sb.append("<div>");sb.append(description);sb.append("</div>");
}
sb.append("<div>");
return sb.toString();
}
});
columns.add(config);
ColumnModel cm = new ColumnModel(columns);
Grid<BeanModel> grid = new Grid<BeanModel>(store,cm);
grid.setAutoExpandColumn("publicNumber");
grid.getView().setEmptyText(strings.pressSearchToView());
grid.setHeight(200);
grid.setAutoHeight(true);
grid.getView().setForceFit(true);
grid.setLoadMask(true);