wxDataViewCtrl how to Hide the RootItem Topic is solved
wxDataViewCtrl how to Hide the RootItem
Hi,
I don't want to show the contents of rootitem, how do I hide it.
I don't want to show the contents of rootitem, how do I hide it.
Thanks
Best Regards
Ellan
Best Regards
Ellan
Re: wxDataViewCtrl how to Hide the RootItem
AFAIK wxDataViewCtrl doesn't have a root item as it's designed for list based and tree based data.
If the data you want to display has a root item, just irgnore it and start filling the wxDVC with the first level of children.
If the data you want to display has a root item, just irgnore it and start filling the wxDVC with the first level of children.
Use the source, Luke!
Re: wxDataViewCtrl how to Hide the RootItem
Is it implemented in the renderer?doublemax wrote:AFAIK wxDataViewCtrl doesn't have a root item as it's designed for list based and tree based data.
If the data you want to display has a root item, just irgnore it and start filling the wxDVC with the first level of children.
wxDVC specifies the custom wxDataViewModel, and the wxDataVeiwRanderer is also customizable, which means that I now need to ignore first level children in the Render () function of my custom renderer?
Thanks
Best Regards
Ellan
Best Regards
Ellan
Re: wxDataViewCtrl how to Hide the RootItem
No. What i meant was that you should interpret the data as if it didn't have a root item.
Use the source, Luke!
Re: wxDataViewCtrl how to Hide the RootItem
Thank you very much for your inspiration,the data really has no root, and the only real root is NULLdoublemax wrote:No. What i meant was that you should interpret the data as if it didn't have a root item.
Thanks
Best Regards
Ellan
Best Regards
Ellan
Re: wxDataViewCtrl how to Hide the RootItem
It is possible, make the root item null. Find the wxDataViewCtrl sample and check the list view implementation of wxDataViewCtrl.
https://github.com/wxWidgets/wxWidgets/ ... s/dataview
https://github.com/wxWidgets/wxWidgets/ ... s/dataview
Re: wxDataViewCtrl how to Hide the RootItem
Hi,
I am studying the dataview sample, and I changed the code to show only the data tree and list in single tab. The diagram as follow:
Is it possible to doing this kind of tree without root?
I have tried to revise the sample code, replace the m_pop by m_root. The result is "Classical music" under "Pop music", how to make all item in parallel?
Thanks again.
Last edited by rocvan on Wed Jun 15, 2022 9:33 am, edited 3 times in total.
Re: wxDataViewCtrl how to Hide the RootItem
I don't understand what you mean with all "all item(s) in parallel".
Use the source, Luke!
Re: wxDataViewCtrl how to Hide the RootItem
I want to the result as follow:
+ "Pop music"
- music 1
- music 2
- music 3
- music 4
Thanks
Last edited by rocvan on Tue Jul 19, 2022 3:48 pm, edited 2 times in total.
Re: wxDataViewCtrl how to Hide the RootItem
"MyMusicTreeModel" needs to be modified for this.
Code: Select all
unsigned int MyMusicTreeModel::GetChildren( const wxDataViewItem &parent,
wxDataViewItemArray &array ) const
{
MyMusicTreeModelNode *node = (MyMusicTreeModelNode*) parent.GetID();
if (!node)
{
return GetChildren( wxDataViewItem(m_root), array ); // new
// array.Add( wxDataViewItem( (void*) m_root ) );
// return 1;
}
Use the source, Luke!
Re: wxDataViewCtrl how to Hide the RootItem
Hello, I'm also a beginner of using wxDataViewCtrl, and I'm try the way doublemax suggest.
I mean I would like to show only the tree node "Pop music" and "Classical music", but NOT the "root" (My Music) node in the dataview sample.
but I see a similar issue reported by another guy in the stackoverflow site, see here:
Add/Remove node to wxDataViewCtrl
There are two answers there. One is the OP's answer, but in his answer, there are many "Cleared()" function call needed. I think that is not necessary.
Another answer is from the VZ(wx developer), but I'm not sure how to solve the issue.
In-fact, I see few resource of the wxDataViewCtrl, I still need some help, thanks.
I mean I would like to show only the tree node "Pop music" and "Classical music", but NOT the "root" (My Music) node in the dataview sample.
but I see a similar issue reported by another guy in the stackoverflow site, see here:
Add/Remove node to wxDataViewCtrl
There are two answers there. One is the OP's answer, but in his answer, there are many "Cleared()" function call needed. I think that is not necessary.
Another answer is from the VZ(wx developer), but I'm not sure how to solve the issue.
In-fact, I see few resource of the wxDataViewCtrl, I still need some help, thanks.
Last edited by ollydbg23 on Sun Sep 10, 2023 9:06 am, edited 1 time in total.
Re: wxDataViewCtrl how to Hide the RootItem
doublemax wrote: ↑Thu Jun 02, 2022 2:32 pm "MyMusicTreeModel" needs to be modified for this.
Code: Select all
unsigned int MyMusicTreeModel::GetChildren( const wxDataViewItem &parent, wxDataViewItemArray &array ) const { MyMusicTreeModelNode *node = (MyMusicTreeModelNode*) parent.GetID(); if (!node) { return GetChildren( wxDataViewItem(m_root), array ); // new // array.Add( wxDataViewItem( (void*) m_root ) ); // return 1; }
Hi, doublemax, with your suggest changes, I see that "My Music" node is not shown, but this change cause many other issue, for example, with this change, when you click on the "Add Mozart" button, nothing happens.
- doublemax@work
- Super wx Problem Solver
- Posts: 474
- Joined: Wed Jul 29, 2020 6:06 pm
- Location: NRW, Germany
Re: wxDataViewCtrl how to Hide the RootItem
That was just an quick-and-dirty patch to see how it works in principle. For a "real" solution, you need to make significant changes to the model. Basically you'd have to check all occurencies of "m_root" and handle each case indiviually.
Re: wxDataViewCtrl how to Hide the RootItem
OK, thanks for the response, let me check all the "m_root" occurrences, and see whether I can fix this issue.doublemax@work wrote: ↑Mon Jul 10, 2023 9:13 am That was just an quick-and-dirty patch to see how it works in principle. For a "real" solution, you need to make significant changes to the model. Basically you'd have to check all occurencies of "m_root" and handle each case indiviually.