PDA

View Full Version : Avoid Grid reconfigure to show the groupedColumn



Nico33
8 Feb 2010, 10:59 AM
Hi all,

I have a grouping grid that has the grouped column not shown.
When I click on a button, I want to hide one column, so I'm using grid.reconfigure.

But after the reconfigure, I can see the grouped column, and I don't want to see it.
How can I keep the grouped column hidden ?

(Note that I want to use the reconfigure option instead of using the sethidden of a column because in my real app, I have many column to hide / show)

Here's my test code (based on the grouping grid example)


public class GroupingGridExample extends LayoutContainer
{
private boolean visible = true;

@Override
protected void onRender(Element parent, int index)
{
super.onRender(parent, index);
setLayout(new FlowLayout(10));

GroupingStore<Stock> store = new GroupingStore<Stock>();
store.add(TestData.getCompanies());
store.groupBy("industry");

final ColumnModel cm = new ColumnModel(GetConfig());

GroupingView view = new GroupingView();
view.setShowGroupedColumn(false);
view.setForceFit(true);

final Grid<Stock> grid = new Grid<Stock>(store, cm);
grid.setView(view);
grid.setBorders(true);

ContentPanel panel = new ContentPanel();
panel.setHeading("Grouping Example");
panel.setCollapsible(true);
panel.setFrame(true);
panel.setSize(700, 450);
panel.setLayout(new FitLayout());
panel.add(grid);

add(panel);

final Button button = new Button("Hide");
button.addSelectionListener(new SelectionListener<ButtonEvent>()
{
@Override
public void componentSelected(ButtonEvent ce)
{
grid.mask("Please wait ...", "x-mask-loading");

DeferredCommand.addCommand(new Command()
{
public void execute()
{
visible = !visible;
if (visible)
button.setText("Hide");
else
button.setText("Show");
ColumnModel cm = new ColumnModel(GetConfig());
grid.reconfigure(grid.getStore(), cm);
grid.unmask();
}
});
}
});
add(button);
}

private List<ColumnConfig> GetConfig()
{
ColumnConfig company = new ColumnConfig("name", "Company", 60);
ColumnConfig price = new ColumnConfig("open", "Price", 20);
ColumnConfig change = new ColumnConfig("change", "Change", 20);
ColumnConfig industry = new ColumnConfig("industry", "Industry", 20);
ColumnConfig last = new ColumnConfig("date", "Last Updated", 20);
last.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/y"));

List<ColumnConfig> config = new ArrayList<ColumnConfig>();
config.add(company);
config.add(price);
if (visible)
config.add(change);
config.add(industry);
config.add(last);

return config;
}
}

thanks for your help

Nico33
10 Feb 2010, 5:33 AM
this is maybe a bug.
I'm using gwt 1.7 & gxt 2.0

Can someone test with gwt 2.0 & gxt 2.1 ?

Nico33
13 Feb 2010, 12:15 AM
I've tried with gwt 2.0 & gxt 2., but still the same problem.

after debbuging the code, I can see that in the renderRows method of GroupingView, the lastGroupField field has a value, so we don't go in the

else if (eg && lastGroupField == null) {
lastGroupField = groupField;
cm.setHidden(colIndex, true);
}
code part.
Then, the column is not hidden

seems to be a bug, but we can contourn this with setting manually the cm.sethidden() to the correct colindex...