View Full Version : Grouping Grid - Group Name does not show up
Mike Lee
5 Oct 2008, 8:08 PM
Hi all
When GroupingGrid is grouped by some columns which is using GridCellRender, the group name will not properly show up.
In my case, i use BeanModel containing a Date field. And i want it to group by Month. So i add a column with GridCellRender to obtain Month column from Date field. But the GroupName does not show up. And i find that it applies to all other fields with GridCellRender.
Do you have suggestion/workaround to make this work
Using gxt-1.1 official release
Thanks
Mike Lee
gslender
5 Oct 2008, 10:41 PM
post some code showing how you are configuring the grid...
I'm using Grid and BeanModel and had to ensure the group renderer returned a string
view.setGroupRenderer(new GridGroupRenderer() {
public String render(GroupColumnData data) {
return ((Category) ((BeanModel) data.gvalue).getBean()).getName();
}
});
Mike Lee
6 Oct 2008, 10:50 AM
Actually, i have tried this method. And found that gvalue come with null instead of the data from the column.
gslender
6 Oct 2008, 3:04 PM
post some code
grant
Mike Lee
8 Oct 2008, 7:51 AM
In the end of code segment, this print out "data.gvalue : null"
// Month Column
SummaryColumnConfig month = new SummaryColumnConfig("month", "Month", 80);
month.setRenderer(new GridCellRenderer<BeanModel>() {
public String render(BeanModel model, String property,
ColumnData config, int rowIndex, int colIndex,
ListStore<BeanModel> store) {
Transaction tran = (Transaction) model.getBean();
model.set("month", DateTimeFormat.getFormat("MMMM").format(tran.getDate()));
return DateTimeFormat.getFormat("MMMM").format(tran.getDate());
}
});
// Create Grid
EditorGrid<BeanModel> grid = new EditorGrid<BeanModel>(store, cm);
grid.setBorders(true);
GroupSummaryView summary = new GroupSummaryView();
summary.setForceFit(true);
summary.setShowGroupedColumn(false);
summary.setEnableGroupingMenu(true);
grid.setView(summary);
grid.getView().setShowDirtyCells(false);
summary.setGroupRenderer(new GridGroupRenderer() {
public String render(GroupColumnData data) {
System.out.println("data.gvalue : " + data.gvalue);
return data.field;
}
});
gslender
8 Oct 2008, 12:05 PM
How is the store being groupby ?
You'll need to post some more code. I've got a grid, using beanmodel and grouping with a summarycolumn etc.. all working fine.
Obviously something is wrong with how you are implementing yours. Can't help unless I see more code/complete code.
cheers,
grant
Mike Lee
9 Oct 2008, 6:47 AM
I am sorry, i just think that is straight forward. Here are the codes.
Thx
// proxy and reader
proxy = new RpcProxy() {
@Override
public void load(Object loadConfig, AsyncCallback callback) {
accountService.getTransactions(callback);
}
};
BeanModelReader reader = new BeanModelReader();
// loader and store
loader = new BaseListLoader(proxy, reader);
// Set Group Store
store = new GroupingStore<BeanModel>(loader);
store.groupBy("month");
// Month Column
SummaryColumnConfig month = new SummaryColumnConfig("month", "Month", 80);
month.setRenderer(new GridCellRenderer<BeanModel>() {
public String render(BeanModel model, String property,
ColumnData config, int rowIndex, int colIndex,
ListStore<BeanModel> store) {
Transaction tran = (Transaction) model.getBean();
model.set("month", DateTimeFormat.getFormat("MMMM").format(tran.getDate()));
return DateTimeFormat.getFormat("MMMM").format(tran.getDate());
}
});
// Column effect
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(month);
ColumnModel cm = new ColumnModel(columns);
// Create Grid
EditorGrid<BeanModel> grid = new EditorGrid<BeanModel>(store, cm);
grid.setBorders(true);
GroupSummaryView summary = new GroupSummaryView();
summary.setForceFit(true);
summary.setShowGroupedColumn(false);
summary.setEnableGroupingMenu(true);
grid.setView(summary);
grid.getView().setShowDirtyCells(false);
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.