GridTreeViewer - ad-hoc setting columns and column groups visible/not visible [message #854506] |
Tue, 24 April 2012 02:24 |
|
I have a GridTreeViewer and I allow the users to customize the display of the grid - they can use a preferences page to add/remove and reorder the columns.
Note that if a column is inside of a column group - all columns within that group stay under that group - they are moved/added/removed as a whole through the preferences page.
If the grid is being displayed, I reorder the columnns, set the visible state, set the colunn width, and refresh the gridviewer as appropriate.
I am finding a couple of strange things - and I believe it's related to the header renderer, but I'm not sure how to fix this as of yet.
1. When I remove the columns in a column group - I do a setVisible(false) and I set the width to 0 - just to be sure. This seems to remove the group, but it seems that the toggle renderer wants to display on a header somewhere - so it moves to the left - even if this column it isn't a group.
2. When not displaying the grid, if I remove enough columns from the display the header gets really tall the next time I draw the grid - widths are good, just the height is ridiculous!
My snippet of creating the grid is as follows:
Composite composite = new Composite(sashForm, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
GridTreeViewer gtv = new GridTreeViewer(composite);
Grid grid = gtv.getGrid();
grid.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
grid.setHeaderVisible(true);
grid.setFooterVisible(true);
grid.setTreeLinesVisible(true);
grid.setVisible(true);
The sashForm is not being moved, so that is not affecting the resize of the header, it's purely just removing columns and drawing the grid (or re-ordering columns).
I'll be happy to provide more information if needed.
Any thoughts/assistance would be greatly appreciated.
Thanks,
Sharon
|
|
|
Re: GridTreeViewer - ad-hoc setting columns and column groups visible/not visible [message #854864 is a reply to message #854506] |
Tue, 24 April 2012 09:55 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Could you please provide a runnable test case so that I can debug the
problem.
Tom
Am 24.04.12 04:24, schrieb Sharon Snyder:
> I have a GridTreeViewer and I allow the users to customize the display
> of the grid - they can use a preferences page to add/remove and reorder
> the columns.
> Note that if a column is inside of a column group - all columns within
> that group stay under that group - they are moved/added/removed as a
> whole through the preferences page.
> If the grid is being displayed, I reorder the columnns, set the visible
> state, set the colunn width, and refresh the gridviewer as appropriate.
>
> I am finding a couple of strange things - and I believe it's related to
> the header renderer, but I'm not sure how to fix this as of yet.
>
> 1. When I remove the columns in a column group - I do a
> setVisible(false) and I set the width to 0 - just to be sure. This
> seems to remove the group, but it seems that the toggle renderer wants
> to display on a header somewhere - so it moves to the left - even if
> this column it isn't a group.
> 2. When not displaying the grid, if I remove enough columns from the
> display the header gets really tall the next time I draw the grid -
> widths are good, just the height is ridiculous!
>
> My snippet of creating the grid is as follows:
> Composite composite = new Composite(sashForm, SWT.NONE);
> composite.setLayout(new GridLayout(1, false));
>
> GridTreeViewer gtv = new GridTreeViewer(composite);
> Grid grid = gtv.getGrid();
> grid.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true,
> 1, 1));
> grid.setHeaderVisible(true);
> grid.setFooterVisible(true);
> grid.setTreeLinesVisible(true);
> grid.setVisible(true);
> The sashForm is not being moved, so that is not affecting the
> resize of the header, it's purely just removing columns and drawing the
> grid (or re-ordering columns).
>
> I'll be happy to provide more information if needed.
>
> Any thoughts/assistance would be greatly appreciated.
>
> Thanks,
> Sharon
|
|
|
Re: GridTreeViewer - ad-hoc setting columns and column groups visible/not visible [message #855251 is a reply to message #854864] |
Tue, 24 April 2012 16:39 |
|
Hi Tom,
While I was working on getting you a runnable example - I came across the workaround for both of the problems. Just set the column visible (true/false). Don't change the column size. This messes up the header height since it thinks it needs to somehow display the text with 0 width (which is basically ridiculous). This also seemed to affect the drawing of the toggle chevrons. Once I stopped changing the size of the column, in addition to setting the visible flag, it all seems to work properly.
Please consider safeguarding against this. Consider the 0 width as a non-visible column maybe and do not calculate the header size for that column maybe?
Just a thought!
I hope my workaround can help others.
-Sharon
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03290 seconds