I use UltraTree 2009.1 and Tree in ViewStyle=Standard
The tree is bound to a datatable ans all nodes are shown fine. In some cases I need to resort my tree. For this reason I have a sort comparer class setting up like this:
Never is sorted and the Compare member of my comparer class is never be called. Thanks for any help.
Markus
Try setting the SortComparer property on the Column instead. If you set the ColumnSet's NodeTextColumn property, use that column, otherwise it will just be the first column in the ColumnSet.
In the standard .NET TreeView there is a TreeViewNodeSorter that can be replaced by a custom NodeSorter which derives from IComparer. This allows to sort the tree based upon information in the TreeNodeTag, for instance.
I am using an UltraTree in Outlook style (multicolumn), and I want to sort the tree using the TreeNodeTag. So I am trying to use the UltraTree.Override.SortComparer and the RefreshSort method to trigger, but it does not work...
What should I do ?
May sounds very simple, but have you tried changing the sort from Default to Ascending, I've just been having a similar problem and that was my issue.
It seems that even if you are not using the sorting, you still need to tell it to do some.
Hello Brian,
well, my tree is still not sorting. No ideas?
I have compared again to the example "Ultra tree Sortimg" and the only differece I found is that the tree in the example is populated from code.
My tree is bound to a dataset with two tables like discussed in that post:
http://community.infragistics.com/forums/p/32122/175770.aspx#175770
Does sorting not work for bound trees???
Thanks for answer. Markus.
Ok, thanks for this advice.
I could you please show me a piece of code of how to set the SortComparer on a column and how to trigger the custom sorting (after the column has been sorted by name for example) using information in the TreeNodeTag of each node ?
For now I have implemented my sorting using the IComparer (on a list this time) by myself with this recursive function :
private void TreeRecursiveSort(UltraTreeNode node) { List<UltraTreeNode> listOfNodes = new List<UltraTreeNode>(); foreach (UltraTreeNode childNode in node.Nodes) listOfNodes.Add(childNode); listOfNodes.Sort(new NodeSorter()); node.Nodes.Clear(); foreach (UltraTreeNode childNode in listOfNodes) node.Nodes.Add(childNode); foreach (UltraTreeNode childNode in node.Nodes) TreeRecursiveSort(childNode); }
I'm still trying to perform my sorting. I have also checked out the example shipped with your product. It looks simple and it works. I can not see any differences to my code. Like mentioned before, my tree is setup as follows:
- ViewStyle=Standard
- Bound to DataSet to a self referncing table. In the initializeDataNode Event I assign a class-instance to the tag object (the tree should be sorted based on this tag object).
- On ColumnSetGenerated-Event I assign the NodeTextColumn and I set the SortComparer property of the NodeTextColumn to mySortCpmparer-Class which implements the IComparer Interface
- After the property form is closed I set the Text of the NodeTextColumn and call tree.RefreshSort()
Are there other properties that I have to set to perform sorting? How I can change the node text?
Thanks for any help.
You have to assing the IComparer implementation to the column's SortComparer property. You can assing the same instance to multiple columns, assuming the implementation acounts for the different columns that are players in the sort criteria.