This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
How can I expand/collapse nodes in a Hierarchical Data Grid? I need this in two contexts:
Thanks |
|
|
Hello We have added Expand and Collapse methods to the data grid. You can call these methods and pass in the data object of the hierarchical row that you want to toggle. For example, if you want to collapse all items, iterate through each object in your items source (except for the first item), and pass each item into the DataGrid.Collapse method. This will collapse all the top level items. We have also added the DataGrid.HierarchicalItemStateChanging event. You can attach an event handler to this to provide your own logic for weather or not a user can expand or collapse an item. The event arguments give you the data item that is requesting to be expanded or collapsed. In the event handler in your scenario, check to see if the given item is the first item in your items source. If it is, then set the CanChangeState property on the event arguments to false. Otherwise do nothing to indicate the user can toggle the state. Here is an example where "Data" is a reference to the items source. Note that this only effects user interaction. You can still programatically effect the expanded state of any item.
These additions will be available in the next nightly build. The next nightly build will be available at around 1200 GMT (about 11 hours from now). You can download nightly builds from your account page: http://www.mindscapehq.com/store/myaccount Jason Fauchelle |
|
|
Great. Thanks! Two quick points.
|
|
|
Hello Nestor
Let me know if you have any questions about this. Jason Fauchelle |
|
|
I'm not following you. By "custom expansion logic returned false" you mean when I set e.CanChangeState = false inside the event HierarchicalItemStateChanging ? |
|
|
Never mind... I tried it and it worked. Thanks. |
|
|
Would it be possible to allow the IsExpanded property to be binded to the View Model? In that way I can control precisely whether I was a node to appear expanded or collapsed after insertion. |
|
|
Hello Nestor We won't be adding this feature in right now, but I have made a note for a possible future feature. Expansion state isn't typically something you'd have in the model objects, though I can see this would be convenient. I hope you are able to live with the Expand and Collapse methods for now. Jason Fauchelle |
|
|
OK. I can live with that. Thanks. Nestor |
|