Hi guys,
I'm looking for a way to have a wxGrid that has collapsable rows. Meaning a row may have one or more rows attached. and by means of a mouseclick these rows appear or disappear (expand/collapse). How would you achieve this. Are there extended wxGrid implementations that do this ?
regards,
Nunki
Collapsable wxGrid
Re: Collapsable wxGrid
wxGrid doesn't support this and i can't think of an easy way to fake it. Look into wxDataViewCtrl.
Use the source, Luke!
Re: Collapsable wxGrid
Hi Nunki,
I also wanted to do something like this a couple of years ago. I searched for a suitable control but was not successful.
The problem with wxDataViewCtrl is that all the collapsing is done in the first column. We wanted the top level branches in the first column, second level branches in the second column, third level branches in the third column etc. etc.
In the end the project got dropped, but the approach we decided on was to create a custom control based on the generic version of wxDataViewCtrl code and using the underlying data wxDataViewTreeStore. Our attempts only got as far as a very quick mock-up with minimal functionality, but actually it wasn't as hard as I had feared, because the generic control drawing is fairly straightforward.
I also wanted to do something like this a couple of years ago. I searched for a suitable control but was not successful.
The problem with wxDataViewCtrl is that all the collapsing is done in the first column. We wanted the top level branches in the first column, second level branches in the second column, third level branches in the third column etc. etc.
In the end the project got dropped, but the approach we decided on was to create a custom control based on the generic version of wxDataViewCtrl code and using the underlying data wxDataViewTreeStore. Our attempts only got as far as a very quick mock-up with minimal functionality, but actually it wasn't as hard as I had feared, because the generic control drawing is fairly straightforward.
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
-
- Filthy Rich wx Solver
- Posts: 235
- Joined: Fri Sep 14, 2012 8:26 am
- Location: Kontich, Belgium
- Contact:
Re: Collapsable wxGrid
Hi iwbnwif,
I've been thinking about this and my idea is that I probably will have to create a class based upon wxGrid to extend it. I tested something else first, I added a column containing the hashkey of the database rows displayed in wxGrid and then hid it with hGrid->HideCol(nLastCol); The effect was that you could not see the column, but it was there and you could access the content of it. Now I was thinking of a grid with the first colum, or the row labels containing a triangular image or + or - image to control whether rows that contain under a master row are shown or hidden. For there is a method in wxGrid hGrid->HideRow(nRow); and hGrid->ShowRow(); That would probably give the effect I'm after. I'll keep on experimenting and will keep you in the loop, though I'm always open for suggestions or remarks.
Regards,
Nunki
I've been thinking about this and my idea is that I probably will have to create a class based upon wxGrid to extend it. I tested something else first, I added a column containing the hashkey of the database rows displayed in wxGrid and then hid it with hGrid->HideCol(nLastCol); The effect was that you could not see the column, but it was there and you could access the content of it. Now I was thinking of a grid with the first colum, or the row labels containing a triangular image or + or - image to control whether rows that contain under a master row are shown or hidden. For there is a method in wxGrid hGrid->HideRow(nRow); and hGrid->ShowRow(); That would probably give the effect I'm after. I'll keep on experimenting and will keep you in the loop, though I'm always open for suggestions or remarks.
Regards,
Nunki