wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
I've encountered an interesting order issue when expanding a child list in wxDataViewModel.
wxDataViewModel::GetChildren passes in a reference to wxDataViewItemArray and is populated with child wxDataViewItem objects.
I'd expect the order that wxDataViewModel::GetValue is called to get the value of child objects would be the order that objects are placed in wxDataViewItemArray; however, this doesn't seem to be the case.
wxDataViewItem child object placed in wxDataViewItemArray is, 0, 1, 2, 3, 4, 5.
the order wxDataViewModel::GetValue asks for child values are: 1,3,5,4,2,0; and this is the order that is display in the list. Interestingly all wxDataViewItem in wxDataViewItemArray are displayed; just in the wrong order. Attached is an image showing the display order in red.
Any idea what is going on here? Why wouldn't wxDataViewModel::GetValue ask for child values in the order placed in wxDataViewItemArray?
[/img]
Thanks,
Patrick
wxDataViewModel::GetChildren passes in a reference to wxDataViewItemArray and is populated with child wxDataViewItem objects.
I'd expect the order that wxDataViewModel::GetValue is called to get the value of child objects would be the order that objects are placed in wxDataViewItemArray; however, this doesn't seem to be the case.
wxDataViewItem child object placed in wxDataViewItemArray is, 0, 1, 2, 3, 4, 5.
the order wxDataViewModel::GetValue asks for child values are: 1,3,5,4,2,0; and this is the order that is display in the list. Interestingly all wxDataViewItem in wxDataViewItemArray are displayed; just in the wrong order. Attached is an image showing the display order in red.
Any idea what is going on here? Why wouldn't wxDataViewModel::GetValue ask for child values in the order placed in wxDataViewItemArray?
[/img]
Thanks,
Patrick
- Attachments
-
- order.png (55.54 KiB) Viewed 1802 times
Re: wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
What platform are you using and do you have a custom wxDataViewModel ?
Unless you explicitly set a sort order, there is no guarantee that the items are displayed in the same order they were inserted. It depends on the model's implementation. Storing items in a linked list would be too slow for large datasets. It's more likely the model would use an unordered map or similar container to store them.
(This is just an educated guess. All 3 major platforms use a different implementations of wxDataViewCtrl, and i don't know the internals of either of them.)
Unless you explicitly set a sort order, there is no guarantee that the items are displayed in the same order they were inserted. It depends on the model's implementation. Storing items in a linked list would be too slow for large datasets. It's more likely the model would use an unordered map or similar container to store them.
(This is just an educated guess. All 3 major platforms use a different implementations of wxDataViewCtrl, and i don't know the internals of either of them.)
Use the source, Luke!
Re: wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
This is windows. I have a Linux implementation but haven't ported and tested yet. And wxWidgets 3.1.5
Yes, wxDataViewModel is custom implementation; however, I do nothing to control how GetValue is called and I populated wxDataViewItemArray in linear order.
Yes, wxDataViewModel is custom implementation; however, I do nothing to control how GetValue is called and I populated wxDataViewItemArray in linear order.
Re: wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
> Unless you explicitly set a sort order, there is no guarantee that the items are displayed in the same order they were inserted. It depends on the model's implementation.
Can you please expand on this? How does one set the order?
Can you please expand on this? How does one set the order?
Re: wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
I don't know too much about wxDVC, but after looking at the methods of related classes:
- when creating a wxDataViewColumn, add the wxDATAVIEW_COL_SORTABLE
- call wxSettableHeaderColumn::SetSortable( true )
- implement sorting related methods in your wxDataViewModel
In general, check the "dataview" sample that comes with wxWidgets.
You could also look at the implementation of the default wxDataViewModel
- when creating a wxDataViewColumn, add the wxDATAVIEW_COL_SORTABLE
- call wxSettableHeaderColumn::SetSortable( true )
- implement sorting related methods in your wxDataViewModel
In general, check the "dataview" sample that comes with wxWidgets.
You could also look at the implementation of the default wxDataViewModel
Use the source, Luke!
Re: wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
Not setting wxDATAVIEW_COL_SORTABLE for this column. This column doesn't have the sort option. However, my other columns are sortable.
wxDataViewColumn("Value", new wxObjectPropValueRender(), 3, wxDVC_DEFAULT_WIDTH, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE);
So I'd expect no sorting and the order would be the order in the wxDataViewItemArray.
wxDataViewColumn("Value", new wxObjectPropValueRender(), 3, wxDVC_DEFAULT_WIDTH, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE);
So I'd expect no sorting and the order would be the order in the wxDataViewItemArray.
Re: wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
I've discovered when I expand a child list the column sort routine is called with 'column' value == 4294967295.
Any explanation as to why there is a column 4294967295 (unsigned)? In a signed form 4294967295 == -1
Nothing in the docs to suggest 4294967295 (-1) is used for expanding child lists.
If I sort column 4294967295 by the index values in wxDataViewItemArray the child list display is ordered correctly.
Any explanation as to why there is a column 4294967295 (unsigned)? In a signed form 4294967295 == -1
Nothing in the docs to suggest 4294967295 (-1) is used for expanding child lists.
If I sort column 4294967295 by the index values in wxDataViewItemArray the child list display is ordered correctly.
Re: wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
It's explained here:
https://docs.wxwidgets.org/trunk/classw ... a765279aed
https://docs.wxwidgets.org/trunk/classw ... a765279aed
Use the source, Luke!
Re: wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
Well as soon as I sort another column all bets are off. All child lists in a wxDataViewModel adopts the 1,3,5,4,2,0 order and there is no way to go back to the original wxDataViewItemArray order 0,1,2,3,4,5 except by closing the window, reopening the window and reloading all the data again.
For some unknown reason sort columns are impacting a non-sorted column.
For some unknown reason sort columns are impacting a non-sorted column.
Re: wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
I have no first-hand experience with wxDVC, so unfortunately i can't help with this. But as it's a relatively old control, i doubt there is a fundamental bug in the sort handling. It's probably a case of bad documentation.
Can you adapt your code to use one of the built-in wxDataViewModels?
Or maybe create an as-simple-as-possible example that shows the problem?
Alternatively you can try asking on the wx-users group where you can reach the core wx developers. This is a user forum.
https://groups.google.com/g/wx-users
However, they will probably ask for a minimal sample, too.
Can you adapt your code to use one of the built-in wxDataViewModels?
Or maybe create an as-simple-as-possible example that shows the problem?
Alternatively you can try asking on the wx-users group where you can reach the core wx developers. This is a user forum.
https://groups.google.com/g/wx-users
However, they will probably ask for a minimal sample, too.
Use the source, Luke!
Re: wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
Ok, I discovered the difference.
When wxDataViewModel::Compare(const wxDataViewItem& item1, const wxDataViewItem& item2,...) is called I need to determine if item1 and item2 are parent wxDataViewItem or child wxDataViewItem? If child, I sort by the order in the wxDataViewItemArray; if parent, I sort by the column.
I was treating all wxDataViewItem as a parent wxDataViewItem which resulted in my child display list adopting the column sort algorithm and getting all jumbled.
Thanks!
When wxDataViewModel::Compare(const wxDataViewItem& item1, const wxDataViewItem& item2,...) is called I need to determine if item1 and item2 are parent wxDataViewItem or child wxDataViewItem? If child, I sort by the order in the wxDataViewItemArray; if parent, I sort by the column.
I was treating all wxDataViewItem as a parent wxDataViewItem which resulted in my child display list adopting the column sort algorithm and getting all jumbled.
Thanks!
Re: wxDataViewModel::GetValue doesn't ask for children in the order placed in wxDataViewItemArray
Hi,
Are you using it as a tree or a list?
Thank you.
Are you using it as a tree or a list?
Thank you.