How to expand all root items in wxDataViewCtrl? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

How to expand all root items in wxDataViewCtrl?

Post by Ronald »

The code below doesn't work

Code: Select all

my_data_view_ctrl->ExpandChildren(wxDataViewItem(nullptr));
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to expand all root items in wxDataViewCtrl?

Post by ONEEYEMAN »

Hi,
What di you mean "doesn't work"?

Thank you.
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: How to expand all root items in wxDataViewCtrl?

Post by Ronald »

ONEEYEMAN wrote: Fri Oct 15, 2021 11:42 am What di you mean "doesn't work"?
The codes tries to expand all items at root level, but nothing expands.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to expand all root items in wxDataViewCtrl?

Post by ONEEYEMAN »

Hi,
Could you if dataview sample works for you?

Thank you.
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: How to expand all root items in wxDataViewCtrl?

Post by Ronald »

ONEEYEMAN wrote: Sat Oct 16, 2021 3:19 am Could you if dataview sample works for you?
The dataview sample has no demo for expanding all items.

Done by
  • Get data from the model
  • Construct wxDataViewItem's by the data
  • Call wxDataViewCtrl::Expand on the wxDataViewItem's
To see if there are better ways.
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to expand all root items in wxDataViewCtrl?

Post by doublemax »

You need to get the root item first. Which wxDataViewModel are you using? Or are you explicitly using wxDataViewTreeCtrl?
Use the source, Luke!
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: How to expand all root items in wxDataViewCtrl?

Post by Ronald »

doublemax wrote: Sat Oct 16, 2021 8:38 am You need to get the root item first. Which wxDataViewModel are you using? Or are you explicitly using wxDataViewTreeCtrl?
model is derived from wxDataViewModel
ctrl is derived from wxDataViewCtrl

I hope an invalid wxDataViewItem is the final root, and in model it is, but for wxDataViewCtrl::Expand, it isn't.
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to expand all root items in wxDataViewCtrl?

Post by doublemax »

wxDataViewCtrl has no concept of "root" items. This is usually something related to tree controls. E.g. wxTreeCtrl has a single root item, but you have the option to hide it, so that only its children and descendants are visible.

So it all depends on your model. If you have one root item, you need to find the corresponding wxDataViewItem and excand it.
If you don't have a root item (or multiple, depending on how you see it), you must find them all and expand these one-by-one.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to expand all root items in wxDataViewCtrl?

Post by ONEEYEMAN »

2OP
What is the reason you are NOT using wxDataViewTreeCtrl? Or even wxTreeCtrl?

Thank you.
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: How to expand all root items in wxDataViewCtrl?

Post by Ronald »

ONEEYEMAN wrote: Sun Oct 17, 2021 1:39 am What is the reason you are NOT using wxDataViewTreeCtrl? Or even wxTreeCtrl?
Multi columns are need.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to expand all root items in wxDataViewCtrl?

Post by ONEEYEMAN »

Hi,
Did you see the damage? I think wxDVTC supports it.
If not - try wxDataViewTreeListCtrl.

Thank you.
Ronald
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Mon Mar 05, 2018 4:17 am

Re: How to expand all root items in wxDataViewCtrl?

Post by Ronald »

ONEEYEMAN wrote: Sun Oct 17, 2021 3:00 pm Did you see the damage? I think wxDVTC supports it.
If not - try wxDataViewTreeListCtrl.
I've checked the doc, no functions for column manipulations, so I think it doesn't support multi columns.

BTW, I could not post due to "The submitted form was invalid ..." yesterday, it occurs frequently recencly.
Post Reply